error : storage class specified for parameter

前端 未结 7 1712
悲&欢浪女
悲&欢浪女 2021-02-01 11:34

I have a C code written. When I compile it on Linux then in the header file it says the following error: storage class specified for parameter i32 , i8 and so

相关标签:
7条回答
  • 2021-02-01 12:10

    I had similar issue, while error was missing the storage class name in static assignment. E.g.:

    .h:
    class MyClass {
       static const int something;
    }
    
    .cpp:
    const int something = 1; // returns error
    const int MyClass::something = 1; // OK
    
    0 讨论(0)
  • 2021-02-01 12:11

    i had the same experience. The problem was at the function prototype declaration in the header file where a semi colon was missing at the end of function declaration.

    The function was indicated in the compilation logs as "In function ... " just before the error snippet

    Hope this helps!!

    0 讨论(0)
  • 2021-02-01 12:11

    To add up on ;: another case can be a missing ) in a function pointer declaration:

    extern void init_callbacks(void (*init)(), void (*end());
    

    (missing closing parenthesis after *end).

    0 讨论(0)
  • 2021-02-01 12:12

    If you are using vim editor, you can easily find missing semicolon by typing:

    /[^;]\s*$
    

    ...and then jump up/down (with N/n), until problematic line is found.

    0 讨论(0)
  • 2021-02-01 12:14

    You have some code somewhere, probably indicated in the full text of the error message, that does something like this:

    void function(static int foo)
    

    The static is not allowed there. It could also be another storage class, like register or extern.

    0 讨论(0)
  • 2021-02-01 12:30

    Chances are you've forgotten a semicolon in a header file someplace. Make sure each line ends in ;

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