c++ - 错误 : variable or field ‘myfunction’ declared void

标签 c++ c gcc compiler-errors

<分区>

在下文中,我没有定义类型doesntexist

void myfunction(doesntexist argument)
{
}

GCC 4.7.2 说“error: variable or field ‘myfunction’ declared void

我的问题是:编译器在这里指代函数名称为 void 而不是参数类型是怎么想的?

[编辑]
在投票之前,请注意这个问题的答案与错误的顺序和-Wfatal-errors停止打印更直接相关的消息有关。这不仅仅是我在尝试一个稍微模糊的编译器消息。

最佳答案

谢谢,@JoachimPileborg。未经编辑的错误日志没有包含任何有用的信息,但它应该有!评论引导我找到问题和解决方案...从我的 makefile 中删除 -Wfatal-errors

19:17 >>> gcc -Wfatal-errors main.c
main.c:2:17: error: variable or field ‘myfunction’ declared void
compilation terminated due to -Wfatal-errors.

并删除 -Wfatal-errors...

19:18 >>> gcc main.c 
main.c:2:17: error: variable or field ‘myfunction’ declared void
main.c:2:17: error: ‘doesntexist’ was not declared in this scope

问题已解决。


对于那些说“为什么首先要使用 -Wfatal-errors ?”的人:我通常不想要所有 错误作为第一个可以触发其余的。在这种情况下,错误似乎是乱序给出的,或者至少是意外的顺序——我假设编译器会首先遇到 ‘doesntexist’ was not declared 错误。

关于c++ - 错误 : variable or field ‘myfunction’ declared void,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19948581/

相关文章:

c - D_GNU_SOURCE 的解释为什么以及何时使用它?

python - shellcode是如何从C生成的? - 带有代码示例

c - 未定义功能感应

c++ - Eclipse NEON : can't find my user-defined class (c++, Linux)

c++ - 在 Exception 类中使用 unique_ptr 是否安全

c++ - 在 C++ 中初始化 const 字符串的静态 const 数组

c - 调试时没有错误或警告

c++ - 使用 RecursiveASTVisitor 访问 Clang AST 时确定 Stmt 的父函数节点

c++ - 交换函数不交换 C++ 中二维数组的元素

c - 如何将 Go 绑定(bind)建模为使用 union 的 C 结构?