Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os_defines.h:44:19: error: missing binary operator before token "(" #970

Closed
joxeankoret opened this issue Feb 13, 2018 · 14 comments
Closed

Comments

@joxeankoret
Copy link

Hi!

I'm trying to build an old Intel PIN tool using the current GitHub's version of the single include file json.hpp. I noticed that it fails building in my system (Ubuntu 16.04 x86_64, tested with g++ 5.0 and 4.9). This the very first error I get:

In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h:482:0,
                 from /usr/include/c++/5/initializer_list:41,
                 from json.hpp:41,
                 from Tracer.h:24,
                 from Tracer.cpp:5:
/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h:44:19: error: missing binary operator before token "("
 #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)
                   ^

I tried including features.h before "json.hpp", defining myself __GLIBC_PREREQ to trick it, but it fails in other ways, so I guess I'm doing something wrong :)

Any ideas?

@theodelrieu
Copy link
Contributor

Could you try to apply a patch similar to this one?

@joxeankoret
Copy link
Author

joxeankoret commented Feb 13, 2018

@theodelrieu I honestly don't know how to apply a similar patch. That patch is changing directly the part where that macros were used. In my case it's failing at a standard include file.

@theodelrieu
Copy link
Contributor

Oh sorry I thought this was in the library's code... This SO post looks a lot like your issue, maybe it can help?

@joxeankoret
Copy link
Author

I tried most of the workarounds there: None worked for me. Before opening an issue I actually tried applying workarounds from that Stack Overflow's post, as it's the very first Google result. Alas, it didn't work for me.

@theodelrieu
Copy link
Contributor

theodelrieu commented Feb 14, 2018

Hmm, seems that including <initializer_list> on your system breaks. What is the stdlibc++ version you're linking against?

EDIT: I guess it's 5.0. Could you write a program which only includes <initializer_list>? It might be one of your compiler flags.

@joxeankoret
Copy link
Author

joxeankoret commented Feb 14, 2018

Nope, that's not the problem (I would have noticed it long ago, as I do code a lot in C++):

$ cat kk.cpp 
#include <initializer_list>

void foo(void) {}

$ g++ -c kk.cpp -o kk -std=c++11
(No error)
$ g++ -v 2>&1 | tail -1
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.6) 

I tried with every GCC versions I have:

$ g++-4.8 -c kk.cpp -o kk -std=c++11
(No error)
$ g++-4.9 -c kk.cpp -o kk -std=c++11
(No error)
$ g++-5 -c kk.cpp -o kk -std=c++11
(No error)

@theodelrieu
Copy link
Contributor

And only including <nlohmann/json.hpp> breaks?

@joxeankoret
Copy link
Author

joxeankoret commented Feb 14, 2018

No, I tried with another old project where I use it (a rather complex one) and everything builds OK. It seems the problem is specific to Intel PIN's headers. If I try to build the most simple of the Intel PIN tools (just enter into $DIR/source/tools/MyPinTool and type 'make'), it compiles OK, but as soon as I include "json.hpp" in MyPinTool.cpp, it breaks. It didn't before with previous versions of Intel PIN. I wonder why...

@theodelrieu
Copy link
Contributor

And including <initializer_list> with Intel PIN's headers break, right?

I've looked at this issue, and it might be related to your problem (if Intel fiddles with glibc headers).

I have no notion of Intel PIN, so I'm afraid I won't be very helpful here :/

@joxeankoret
Copy link
Author

Yes, you're right, by simply adding that include file it breaks. Thanks a lot for the help!

@theodelrieu
Copy link
Contributor

I wish you good luck!

@nlohmann
Copy link
Owner

So this is not an issue of this library (other than it including <initializer_list>?

@joxeankoret
Copy link
Author

Nope, my issue has nothing to do with this library. I'm closing the issue. Again, thanks for the help!

@standupforyourself
Copy link

standupforyourself commented Apr 21, 2024

No, I tried with another old project where I use it (a rather complex one) and everything builds OK. It seems the problem is specific to Intel PIN's headers. If I try to build the most simple of the Intel PIN tools (just enter into $DIR/source/tools/MyPinTool and type 'make'), it compiles OK, but as soon as I include "json.hpp" in MyPinTool.cpp, it breaks. It didn't before with previous versions of Intel PIN. I wonder why...


I had the same issue yesterday. and I solved it by setting CPLUS_INCLUDE_PATH to the right value, it was "/usr/include/jsoncpp/json" which was wrong, the right value should be "/usr/include/jsoncpp".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants