expected unqualified-id before string constant

后端 未结 3 1079
傲寒
傲寒 2021-02-05 03:20

I\'m currently writing a C++ application which implements an Oscillator in conjuction with math.h. The code I have should work fine for the application (trying to compile an obj

相关标签:
3条回答
  • 2021-02-05 03:32

    Your code has multiple problems:

    • You need to fully qualify names(void oscillators::print_table() instead of just void print_table()) in oscillators.cpp
    • You probably need to #include "oscillators.h" into oscillators.cpp
    • You need to properly declare variables in implementation
    • Add missing semicolons.

    But I guess that specific error is caused by missing semicolon after class definition in header file. Just add it like:

        std::vector<double> gtable_; // Will contain a wavetable with a guard point.
    };
    #endif
    
    0 讨论(0)
  • 2021-02-05 03:36

    Another way to produce this error: define a macro to a string constant, and later, use the macro name as the name of a string constant. Example

    #define FOO "bar"
    static const char FOO[] = "bar"; // <-- Error "expected unqualified-id before string constant".
    

    The obvious answer is to remove one of the definitions, or change the name of one.

    0 讨论(0)
  • 2021-02-05 03:44

    This is a simple problem.

    You just forgot the semi colon at the end of your header file.

    The compiler errors you get for missing the semi colon at the end of a class definition are very hard to relate to the actual problem - just get in the habit of checking that when you get errors after you create a class.

    0 讨论(0)
提交回复
热议问题