Linux 错误:为参数指定的存储类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3676969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error : storage class specified for parameter
提问by SPB
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 on
我写了一个 C 代码。当我在 Linux 上编译它然后在头文件中它说以下错误: storage class specified for parameter i32 , i8
等等
typedef int i32;
typedef char i8;
采纳答案by Featherlegs
Chances are you've forgotten a semicolon in a header file someplace. Make sure each line ends in ;
您可能已经忘记了头文件中某个地方的分号。确保每一行都以;
回答by nmichaels
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
.
该static
是不允许存在。它也可以是另一个存储类,例如register
或extern
。
回答by LDL
I incurred this same error once. The solution was to browse around files and look for pending statements (like a non-closed parenthesis, or a missing semicolon.) Usually it's really a trivial error, but the compiler complains.
我曾经犯过同样的错误。解决方案是浏览文件并查找挂起的语句(如非闭括号或缺少分号)。通常它确实是一个微不足道的错误,但编译器会抱怨。
The bad news is that it doesn't always complain at the right line (or even in the right file!) The good news is that in these cases it says something useful like:
坏消息是它并不总是在正确的行(或什至在正确的文件中!)抱怨,好消息是在这些情况下它会说一些有用的东西,例如:
WRONGFILE.h: In function ‘FUNCTION_OF_ANOTHER_FILE_WRT_WRONG_FILE'"
WRONGFILE:line:col: error: storage class specified for parameter ‘param' before.
Go and check in that other reported file.
去检查其他报告的文件。
回答by Anurag Dixit
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!!
希望这可以帮助!!
回答by Matthieu
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
).
(在 之后缺少右括号*end
)。
回答by ahol967
If you are using vim editor, you can easily find missing semicolon by typing:
如果您使用的是 vim 编辑器,您可以通过键入以下内容轻松找到丢失的分号:
/[^;]\s*$
...and then jump up/down (with N/n), until problematic line is found.
...然后向上/向下跳(用 N/n),直到找到有问题的行。
回答by igraczech
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