From: William S F. <ws...@fu...> - 2006-08-31 20:48:03
|
Alexandre Gillet wrote: > Hi, > > I am trying to wrappe a c++ library, but I get an syntax error while > running swig on my header file. > Swig give me : Error: Syntax error in input(3). at line in bold ( line > starting with static const int PIX_SIZE in following code ( last line) ) > Any idea how I can get rid of the problem. > Thanks > Alex > > > The header file contains: > class TrackerImpl : public Tracker > { > public: > enum { > PATTERN_WIDTH = __PATTERN_SIZE_X, > PATTERN_HEIGHT = __PATTERN_SIZE_Y, > PATTERN_SAMPLE_NUM = __PATTERN_SAMPLE_NUM, > > MAX_LOAD_PATTERNS = __MAX_LOAD_PATTERNS, > MAX_IMAGE_PATTERNS = __MAX_IMAGE_PATTERNS, > WORK_SIZE = 1024*MAX_IMAGE_PATTERNS, > > #ifdef _OLD_MSCOMPILER_ > PIX_FORMAT = __PIX_FORMAT, > > // calculate pixel size from pixel format > PIX_SIZE = PIX_FORMAT==PIXEL_FORMAT_LUM ? 1 : > (PIX_FORMAT==PIXEL_FORMAT_RGB565 ? 2 : > ((PIX_FORMAT==PIXEL_FORMAT_RGB || > PIX_FORMAT==PIXEL_FORMAT_BGR) ? 3 : 4) ), > #endif //_OLD_MSCOMPILER_ > > #ifdef SMALL_LUM8_TABLE > LUM_TABLE_SIZE = (0xffff >> 6) + 1, > #else > LUM_TABLE_SIZE = 0xffff + 1, > #endif > }; > > #ifndef _OLD_MSCOMPILER_ > // These are used in comparisons with other enums, therefore > they > // can't be anonymous enums > static const int PIX_FORMAT = __PIX_FORMAT; > *static const int PIX_SIZE = PIX_FORMAT==PIXEL_FORMAT_LUM ? > 1 :(PIX_FORMAT==PIXEL_FORMAT_RGB565 ? 2 :((PIX_FORMAT==PIXEL_FORMAT_RGB > || PIX_FORMAT==PIXEL_FORMAT_BGR) ? 3 : 4) );* > > #endif //_OLD_MSCOMPILER_ > > > I'm afraid that SWIG doesn't like all the ternary operators. You'll either have to modify your code to use a #ifdef SWIG macro in your header file, or avoid using %include of the header file and instead copy a workaround version into your interface file. Please raise a bug about this. William |