[英]gcc c Compiler error
When attempting to compile 尝试编译时
#include<stdio.h>
int main(){
printf("Hello World");
return 0;
}
I get the following errors with Solaris11 gcc: 我在Solaris11 gcc中收到以下错误:
hello.c:4:23: error: expected expression before ';' hello.c:4:23:错误:“;”之前的预期表达式 token
代币
hello.c:6:1: error: expected ';' hello.c:6:1:错误:预期为';' before '}' token
在“}”标记之前
Visual C++ can compile this code. Visual C ++可以编译此代码。
第四行( return
语句)中的“;”不是标准的“;”。
To the naive reader, what you have in the question is valid C. 对于天真的读者,您所遇到的问题是有效的C。
However, in order to achieve maximum portability, C compilers are allowed to be extremely fussy about the characters that you are allowed to type into your editor as a candidate for compilation. 但是,为了实现最大的可移植性,允许C编译器对允许您在编辑器中键入作为编译候选对象的字符非常挑剔。
I suspect that you have a character in the file that is not part of the ASCII set. 我怀疑您文件中的字符不是ASCII集的一部分。
I suggest you re-type the code from scratch, using no other character than ASCII, and watch the error disappear. 我建议您从头开始使用其他字符(不使用ASCII)重新输入代码,然后观察错误消失。
Once you've done that, "diff" that with your original version. 完成此操作后,请与原始版本进行“比较”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.