我正在尝试编译一个非常简单的 C 程序。使用自动安装程序安装 MinGW,然后在我的环境变量中添加 C:\MinGW\bin。
test.c
#include <stdio.h>
int main()
{
printf("Hello");
return 0;
}
当我编译这个时:
gcc test.c -o test.exe
但是我得到了这个错误,
test.c: In function 'main': test.c:5:12: warning: character constant too long for its type [enabled by defau lt] test.c:5:5: warning: passing argument 1 of 'printf' makes pointer from integer w ithout a cast [enabled by default] c:\mingw\bin../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h:294:37: note: expected 'const char *' but argument is of type 'int'
原谅我是菜鸟,努力学习一些有值(value)的东西。谢谢!
最佳答案
您收到的错误消息与 GCC 为以下代码生成的错误消息完全匹配:
#include <stdio.h>
int main()
{
printf('Hello');
return 0;
}
那是双引号被单引号代替了。
使用记事本或更好的 Notepad++ 检查发生了什么。
关于c - mingw c 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10756815/