Using ofxOSC with another program causes bizarre STL errors.

Hey All,

I have been busy today customising Celestia, to allow it to take incoming OSC messages, to allow for remote control from OpenFrameworks.

You can download my customised source from here:

I have already included OSCPack ( and compiled it successfully within my customised version of Celestia, so I know the problems described below aren’t to do with that addition.Zach Gage put me on to the iPhone version of OSCPack, which gets around a nasty “nil” bug with using C++ and Objective C together.

The problems arise when I attempt to add the OSCReceiver class to the Celestia project.

I have made additions to celestiacore.h, celestiacore.cpp, in the CelestiaCore::CelestiaCore() constructor and the CelestiaCore::tick() methods.

I get this error multiple times:

stl_deque.h: In member function 'void std::_Deque_base<_Tp, _Alloc>::_M_initialize_map(size_t)':  
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/stl_deque.h:452: error: expected unqualified-id before '(' token  

I realise that ofxOSC uses a deque, but for the life of me haven’t been able to track down the problem. The error is obviously_not_with the std library.


I am compiliing on OS X 10.5.6 on a Macbook Pro (Intel).

My feeling is that somehow a constant or keyword has been used in the ofxOSC code, and that this causes the error messages above. Or is it the usage of the std namespace in celestiacore.cpp?

All my additions to Celestia are in the celestiacore.cpp and .h files. The Xcode project can be found in the celestia.xcodeproj in the macosx folder of the zip file linked to above.

I took the ofxOSC addon code from 00573-Xcode-Fat-YCAM-WithGui OF version.

You may need to download Celestia and copy the CelestiaResources folder to the “Application Support” folder in your “Library” folder (’~/Library/Application Support’) in order for the data files to be loaded correctly, but at the moment the program doesn’t even get that far. Removing the additions allows the program to build correctly.

If anyone has any ideas, I’d love to hear them.



Hey joel, I don’t wanna hijack your thread, but whats that about the iphone / oscPack version? I’m getting a nasty crash bug on iPhone in oscpack and I can’t find out what it is. It’s just a ’ “EXC_BAD_ACCESS’ in a thread that oscPack creates, and only happens on iPhone (not simulator). I’ve downloaded the oscpack source and compiled on iphone but just can’t fix it!

hi Joel,

wow - i really have no idea. my immediate thought is that somehow Celestia or OSCpack is including a different STL than the one that ships with the iPhone SDK. in particular, this looks a little strange, maybe, but i’m not sure what STL errors like this usually look like…

stl_deque.h: …
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/stl_deque.h:452: …

why are there two ‘stl_deque.h’ lines shown, and why is only one of them showing a full path? (is this normal? i cannot recall.) is it including stl_deque.h from two different places? should you be compiling for iPhone or 10.4u?

in MSVC there’s a switch about verbose header includes that prints a tree of all the includes so you can see what’s including what… it could be a case of just moving the #include ofxOsc* stuff before the #include celestia* stuff, or vice versa. if i get a chance i will boot back into OSX, download and see if i can compile it this afternoon…

Hey joel - I am pretty sure it has something to do with std::max - though I have no idea why.

Where ever it errors always has a std::max on that line.

Removing your ofxOsc.h includes and just trying to do:

replicates the issue.

Will let you know if I find out more.

Hey Joel

looks like max was being redefined in celutil/util.h

#ifndef min  
#define min(a, b) ((a) < (b) ? (a) : (b))  
#ifndef max  
#define max(a, b) ((a) < (b) ? (b) : (a))  

If you comment this out the deque error goes away - but then there are some other errors because the stl max is more fussy about what types it has

so if you change it to

#ifndef MIN  
#define MIN(a, b) ((a) < (b) ? (a) : (b))  
#ifndef MAX  
#define MAX(a, b) ((a) < (b) ? (b) : (a))  

then compile and swap the lower case min and max for uppercase wherever you get min max errors.

Should be in two places then it compiles.


Hey All,

First of all, here is a link to the ofxOSC that I got from Zach Gage, I am sure he won’t mind me passing it on.

Second, I should make it clear that I am making this application for OSX, not for iPhone. i had to use the OSC bits above, as the program I am trying to customise is a Cocoa port of an original Unix/Win Program. “nil” is a reserved word on Cocoa, and so ofxOSC had to be altered by Zach Gage to use “nill” instead.

Perhaps std::max is breaking things? Is it a keyword in Cocoa? (Same as the nil problem described above?)

Could it be something to do with threads? Non-thread safe libraries vs. safe ones?

I have reposted my source with the comment line:


Before any additions.

I have included OFXOSC (receiver only) and OSCPack (from above) in the “other sources” folder of the XCode project.

The error is repeated 28 times, so I include it once only below:

    cd /Users/joel/Documents/Projects/neuGalleryShow/CelestiaSRC/celestia-1.5.1/macosx  
    /Developer/usr/bin/gcc-4.0 -x objective-c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wmissing-braces -Wunused-function -Wunused-variable -Wunknown-pragmas -Wsign-compare -DPNG_SUPPORT -DCELX -DLUA_USE_MACOSX -DLUA_VER=0x050100 -DREFMARKS=1 -DDEBUG=1 -mfix-and-continue -fvisibility-inlines-hidden -gdwarf-2 -I/Users/joel/Documents/Projects/neuGalleryShow/CelestiaSRC/celestia-1.5.1/macosx/build/ -F/Users/joel/Documents/Projects/neuGalleryShow/CelestiaSRC/celestia-1.5.1/macosx/build/Development -I/Users/joel/Documents/Projects/neuGalleryShow/CelestiaSRC/celestia-1.5.1/macosx/build/Development/include -I../src -I/Users/joel/Documents/Projects/neuGalleryShow/CelestiaSRC/celestia-1.5.1/macosx/build/ -fexceptions -fpermissive -include /var/folders/jf/jfXGSPjaE78yM+pzV8-YtE+++TI/-Caches-/ -c /Users/joel/Documents/Projects/neuGalleryShow/CelestiaSRC/celestia-1.5.1/macosx/ -o /Users/joel/Documents/Projects/neuGalleryShow/CelestiaSRC/celestia-1.5.1/macosx/build/  
/usr/include/c++/4.0.0/bits/stl_deque.h: In member function 'void std::_Deque_base<_Tp, _Alloc>::_M_initialize_map(size_t)':  
/usr/include/c++/4.0.0/bits/stl_deque.h:452: error: expected unqualified-id before '(' token  
/usr/include/c++/4.0.0/bits/deque.tcc: In member function 'void std::deque<_Tp, _Alloc>::_M_reallocate_map(size_t, bool)':  
/usr/include/c++/4.0.0/bits/deque.tcc:747: error: expected unqualified-id before '(' token  
	/usr/include/c++/4.0.0/bits/stl_deque.h:452: error: expected unqualified-id before '(' token  
	/usr/include/c++/4.0.0/bits/deque.tcc:747: error: expected unqualified-id before '(' token  

Damnit it Theo! You are too fast!

Thanks to everyone, I’ll give it a go.