error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before

后端 未结 1 1649
[愿得一人]
[愿得一人] 2021-01-29 16:13

Yes, I know this question has been asked numerous times previously, however I am racking my brain trying to figure out what is causing the error as I cannot identify where the u

相关标签:
1条回答
  • 2021-01-29 17:12

    This time it's not a missing semicolon, but a completely different language. The code you're trying to compile is in C++, not C. That's why you get syntax errors from a C compiler.

    To fix this (and compile the code as C++), rename the file from .c to .cpp:

    mv list.c list.cpp
    

    And use g++ to compile it, not gcc:

    g++ -o list list.cpp
    
    0 讨论(0)
提交回复
热议问题