3

if I build and run a project, basically a stub generated by the Qt framework on Mac OS 10.6, I get this error output:

/Users/home/Qt5.0.1/5.0.1/clang_64/include/QtCore/qisenum.h:53: Error:token is not a valid binary operator in a preprocessor subexpression
#    if __has_extension(is_enum)
    ~~~~~~~~~~~~~~~^

I can´t find a solution to this, although I read that other Mac users seem to have the same problem. Anyone knows how to solve this?

jww
  • 97,681
  • 90
  • 411
  • 885
最白目
  • 3,505
  • 6
  • 59
  • 114

5 Answers5

2

I have found the solution. Just copy the latest qisenum.h file from here and replace it in clang_64/include/QtCore folder in your Qt creator installation, it will work fine.

p.i.g.
  • 2,815
  • 2
  • 24
  • 41
get
  • 36
  • 1
1

This issue is resolved in this forum post.

It is basically an issue with your version of clang

p.i.g.
  • 2,815
  • 2
  • 24
  • 41
fjardon
  • 7,921
  • 22
  • 31
1
#    if __has_extension(is_enum)
         ~~~~~~~~~~~~~~~^

That's a Clang language extension called feature checking macros. They've been around a long time for Clang. GCC provided them starting at GCC 5.0, IIRC.

__has_extension can be tested as a preprocessor macro. So you test for the presence of the macro first, and then you test for the feature:

#if defined(__has_extension)
# if __has_extension(is_enum)
   ...
# endif
#endif

__has_extension(is_enum) must be on a separate line.

It works for include files, too. From the Crypto++ project an rdrand.cpp file:

# include <immintrin.h> // rdrand, MSC, ICC, and GCC
# if defined(__has_include)
#  if __has_include(<x86intrin.h>)
#   include <x86intrin.h> // rdseed for some compilers, like GCC
#  endif
# endif
jww
  • 97,681
  • 90
  • 411
  • 885
1

In my case the reason of the same error was that Preprocessor macro name in Target Build Settings contained hyphen sign '-', something like that TEST-DEBUG=1.

Xcode build configuration names with hyphens ('-') cause pods build failures

d.rozumeenko
  • 126
  • 2
  • 3
0

My case is:

#define USE_LIBICONV 1 # xxxxxx

Error

Token is not a valid binary operator in a preprocessor subexpression

Solution:

remove typo comments after #define

=> change # to //

#define USE_LIBICONV 1 // xxxxxx

then can use macro normally:

#if USE_LIBICONV
...
#endif
crifan
  • 12,947
  • 1
  • 71
  • 56