Friday, December 7, 2007

Building Firebird 2.0x MacOS - semaphore.h

If you download the Firebird Source Code and want to build your own version of Firebird 2.0x on MacOS 10.4 (Tiger) you will probably have to make a minor change to the code. Seems there are changes in /usr/include/sys/semaphore.h between 10.4 and 10.5 to make semaphore.h more compliant.
We use (for Mac purposes) the following in src/common/classes/semaphore.h at line 106

if (sem == SEM_FAILED) {

Which seems obvious right?

Well on 10.4 the build will fail with the following error:

make -f ../gen/Makefile.libfbclient libfbclient
g++ -DSUPERCLIENT -D_THREAD_SAFE -I../src/include/gen -I../src/include -I../src/vulcan -I../extern/icu/source/common -I../extern/icu/source/i18n -DNAMESPACE=Vulcan -ggdb -DDARWIN -pipe -p -MMD -fPIC -fno-common -Wall -arch i386 -DDEV_BUILD -c ../src/jrd/alt.cpp -o ../temp/superclient/jrd/alt.o
../src/include/../jrd/../common/classes/semaphore.h: In constructor 'Firebird::SignalSafeSemaphore::SignalSafeSemaphore()':
../src/include/../jrd/../common/classes/semaphore.h:106: error: ISO C++ forbids comparison between pointer and integer
../src/jrd/../jrd/common.h: At global scope:

A quick check of /usr/include/sys/semaphore.h on 10.4 and 10.5 shows:

10.4 #define SEM_FAILED -1
10.5 #define SEM_FAILED ((sem_t *)-1)

Hmm - 10.5 looks more like what we would expect (same as linux for example)
A problem with types? Looks like it.

Change line 106 in src/common/classes/semaphore.h

if (sem == SEM_FAILED) {
if (sem == (sem_t*)SEM_FAILED) {

Or upgrade your /usr/include/sys/semaphore.h to something thats correct!

No comments: