What does the compiler error “missing binary operator before token” mean?

后端 未结 4 1838
执念已碎
执念已碎 2020-11-30 09:40

I recently got the following error when trying to compile with gcc:

error: missing binary operator before token \"(\"

Web and SO

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 10:33

    If you are on Linux, make sure that you do not have a header named features.h inside your project files. I had one with this name, which resulted in:

    /usr/include/x86_64-linux-gnu/bits/huge_val.h:25: error: function pointer expected

    or

    /usr/include/bits/huge_val.h:26:18: error: missing binary operator before token "("

    That is because some system headers like huge_val.h use macros like __GNUC_PREREQ that are defined by /usr/include/features.h (learn more about this header in this SO question).

    In my case I first saw this error when I started to use gcc's -I option which suddenly made gcc select my project include directory before the default system include directories.

提交回复
热议问题