Make new library project in Xcode (8.3.2), choose Framework: STL (C++ Library), Type: Static, and name it "MyLibrary". You'll get starting files MyLibrary.hpp, MyLibraryPriv.hpp, MyLibrary.cpp. Create new header file, semaphore.h, an place it with in the same folder as all the others. This file should have an include guard definition semaphore_h
.
Add in MyLibrary.cpp the following lines:
#include <semaphore.h>
#ifdef _BSD_SEMAPHORE_H
#warning _BSD_SEMAPHORE_H
#endif
#ifdef semaphore_h
#warning semaphore_h
#endif
I am including here a system header file, not the file I just added, but the result of the build is that semaphore_h
will be written as a build warning, which is wrong. If I rename my file in Finder then _BSD_SEMAPHORE_H
is written, as it should be.
Is this a bug? How to workaround it? I have a header in my project that shares the same name as a system header, but I would rather not change the name.
Strange thing is, if it were an app project (Command Line Tool) then it would work as expected. #include <semaphore.h>
would cause _BSD_SEMAPHORE_H
warning and #include "semaphore.h"
would cause semaphore_h
warning. Library project behaves differently than app project.