1

I'm getting the Syntax Error in input(1) error for this line of code, in C when I do:

swig -python myfile.i in console.

It concerns the following code, specifically the last line of these typedefs.

typedef unsigned short WORD;    
typedef unsigned int DWORD;
typedef unsigned long long QWORD;
typedef unsigned char BYTE;     
typedef unsigned int bool; //<= THIS LINE OF CODE TRIGGERS THE ERROR.

As far as I know, bool is not defined in C so I would think swig would let this go with no issue. I compiled as c in VS 2010 and it was just fine.

Mark

limenuke
  • 53
  • 2
  • 7

1 Answers1

3

C does have a bool type (actually a macro) but it is a C99 feature and you have to include stdbool.h to get bool; you only have _Bool if you don't include stdbool.h.

VS2010 doesn't support C99, it only supports C89 (AFAIK) so the typedef will work fine with that.

I'd guess that something somewhere is pulling in stdbool.h and that is messing up your typedef as it will look like this:

typedef unsigned int _Bool;

when the compiler sees it and the compiler won't like that at all.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
  • What do you think GCC / swig will see it as? I don't have stdbool.h included anywhere explicitly. I've got #include #include #include included. Do any of those include stdbool? – limenuke Jun 15 '11 at 19:11
  • @limenuke: I don't who is pulling in `stdbool.h`. Try a simple "hello world" program that uses those headers and includes your `typedef unsigned int bool;`. Maybe swig is pulling it in somewhere. – mu is too short Jun 15 '11 at 19:15
  • I found I've no need to use the lowercase bool and will be using BOOL (which I've tested and works). Either way, I couldn't get to test out your method. Thanks anyways! – limenuke Jun 15 '11 at 21:02