c - mingw c 编译

标签 c compilation mingw

我正在尝试编译一个非常简单的 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/

相关文章:

c - 运行时检查失败 #2 - 变量 'd' 周围的堆栈已损坏。 (Visual Studio下的C编程)

c - C 程序中使用的适当数据类型

C 光标问题

c - C 方法中有关 Float 和 Int 的错误

c - 优化: Faster compilation

c - Orwell 的 MinGW 和 TDM Dev-C++ 版本有什么区别?

c - FindFileFirst() 每个路径的句柄值无效

linux编译文件,windows运行

c++ - 明威。如何使用静态和动态链接

c++ - 如何获得 4.2 版的 g++/gcc for windows?