使用makefile编译错误

Wiz*_*ard -1 makefile

我在c中编写了一个程序,我在windows上的cygwin中使用make文件来编译文件.在Visual Studio中执行完全正常,但是当我尝试使用我的make文件时,会发生以下情况:

错误:

$ make
gcc    -c -o mathTable.o mathTable.c
mathTable.c:1:1: error: stray ‘\377’ in program
 ??# i n c l u d e   < s t d l i b . h >
 ^
mathTable.c:1:2: error: stray ‘\376’ in program
 ??# i n c l u d e   < s t d l i b . h >
  ^
mathTable.c:1:3: error: stray ‘#’ in program
 ??# i n c l u d e   < s t d l i b . h >
   ^
mathTable.c:1:4: warning: null character(s) ignored
 ??# i n c l u d e   < s t d l i b . h >
    ^
mathTable.c:1:6: warning: null character(s) ignored
 ??# i n c l u d e   < s t d l i b . h >
      ^
mathTable.c:1:5: error: unknown type name ‘i’
 ??# i n c l u d e   < s t d l i b . h >
     ^
...
...
...
mathTable.c:73:21: warning: null character(s) ignored
mathTable.c:73:25: warning: null character(s) ignored
mathTable.c:73:27: warning: null character(s) ignored
mathTable.c:74:1: warning: null character(s) ignored
mathTable.c:75:1: warning: null character(s) ignored
mathTable.c:75:3: warning: null character(s) ignored
mathTable.c:76:1: warning: null character(s) ignored
mathTable.c:77:1: warning: null character(s) ignored
mathTable.c:78:1: warning: null character(s) ignored
mathTable.c:79:1: warning: null character(s) ignored
make: *** [<builtin>: mathTable.o] Error 1
Run Code Online (Sandbox Code Playgroud)

我开始研究C所以我不太确定是什么导致了这一点.这看起来很奇怪.也许与Linux有关?因为我不处理跨平台(因为我认为我不需要).

ddb*_*bug 8

这可能是因为您的文件具有Windows UTF-16格式.也许它包含您母语的字符串或注释.Visual C++编译器理解这一点,但GCC(Mingw)没有.无需标记即可以UTF-8格式保存文件.


Max*_*kin 7

这不是GNU Make错误.

编译器抱怨您的源文件编码错误.您需要在gcc编译器中使用ASCII或UTF-8 .

或尝试-finput-charset=UTF-16编译选项.