[Prev][Next][Index]
Re: extern "C" and #include
- From: Beata Winnicka <bfatyga@slab.extreme.indiana.edu>
- Date: Fri, 28 Apr 95 12:04:02 -0500
- To: Lars Thomas Hansen <lth@cs.uoregon.edu>
- Subject: Re: extern "C" and #include
- Cc: sage-bugs@rainier.extreme.indiana.edu
- Sender: owner-sage-bugs@extreme.indiana.edu
Lars wrote:
There are two files, bug4.pc and bug4.h. Here's bug4.pc:
extern "C" {
// include file defines TRUE and FALSE in an enum
#include "bug4.h"
};
main()
{
if (TRUE)
1 == 2;
else
1 == 3;
}
and here's bug4.h:
typedef enum { FALSE = 0, TRUE = 1 } mybool;
When compiled, this produces the error message
blackrabbit(46) % pc++ bug4.pc
Error on line 8 of bug4.pc: Undefined symbol 'TRUE'
Error in pc++ while executing:
-------> pC++2dep TEMP_pC++.C
When I remove the 'extern "C"' wrapper, it compiles fine. Both CC
and
gcc compile the program w/o compile-time errors. The extern C
wrapper
cannot easily be removed, as the include file is used with both C and
C++ and defines a lot of library functions written in C.
__________________
Fixed and CVS'ed. For future reference, below is a copy of my earlier
message to Lars, which I forgot to CC to sage-bugs:
>we have this recurring problem throughout the parser, in that the
>parser likes to treat a pair of curly braces { } as a new scope,
>whereas with extern "C" {}, it obviously is not. This might be yet
>another bug of this kind.
It was indeed, --Beata