tags:

views:

84

answers:

2

I just picked up an old project and I'm not sure what the following error could mean.

g++ -o BufferedReader.o -c -g -Wall -std=c++0x -I/usr/include/xmms2 -Ijsoncpp/include/json/ -fopenmp -I/usr/include/ImageMagick -I/usr/include/xmms2 -I/usr/include/libvisual-0.4 -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SCRIPT_LIB -DQT_SHARED -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtScript BufferedReader.cpp
In file included from BufferedReader.cpp:23:
/usr/include/string.h:36:42: error: missing binary operator before token "("
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.3/../../../../include/c++/4.4.3/cwchar:47,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.3/../../../../include/c++/4.4.3/bits/postypes.h:42,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.3/../../../../include/c++/4.4.3/iosfwd:42,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.3/../../../../include/c++/4.4.3/ios:39,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.3/../../../../include/c++/4.4.3/istream:40,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.3/../../../../include/c++/4.4.3/sstream:39,
                 from BufferedReader.cpp:24:

At line 24 of BufferedReader.cpp is #include <string.h>. I've tried it with just <string> but get the same thing. Any clue?

Here's the snippet of code from string.h

/* Tell the caller that we provide correct C++ prototypes.  */
#if defined __cplusplus && __GNUC_PREREQ (4, 4) //line 36
# define __CORRECT_ISO_CPP_STRING_H_PROTO
#endif

Does that mean __GNUC_PREREQ isn't defined?

Edit:

Changing -Ijsoncpp/include/json/ to Ijsoncpp/include stopped the errors. I noticed I was including <json/json.h>.

I'm about to switch to JsonGlib though, which is the reason I pulled the project up again. So it's all good. :)

+2  A: 

Try #include <cstring>.

Donotalo
cstring seems to include string.h and the error still happens.
Scott
@Scott, yes but if you're doing `C++`, it is still recommended to include `cstring` instead of `string.h`.
ereOn
@ereOn: Ok. Thanks.
Scott
+3  A: 

Strange errors like this usually happen in the include file before the one you included. This is often when a class in a header file does not end with a semicolon (;). Check which file in included on line 22 of BufferedReader.cpp and check that file for syntax errors towards the end.

camh