Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help with this compile error

Tags:

c++

linux

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. :)

like image 660
Scott Avatar asked Dec 18 '22 00:12

Scott


2 Answers

Try #include <cstring>.

like image 174
Donotalo Avatar answered Dec 19 '22 14:12

Donotalo


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.

like image 31
camh Avatar answered Dec 19 '22 12:12

camh