【发布时间】:2014-05-21 20:31:28
【问题描述】:
每次我尝试编译一个简单的 hello world 程序时,我都会得到一个充满错误的控制台。我有 DevC++,当我使用 IDE 时,它编译得很好并且工作得很好,但我开始从 Notepad++ 和命令行做所有事情。这是我的错误:
C:\Users\root\Desktop>g++ helloworld.c -o helloworld.exe
In file included from c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/
4.4.3/../../../../include/stdio.h:26,
from helloworld.c:1:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686
-w64-mingw32/include/stddef.h:20: error: expected constructor, destruc
tor, or type conversion before '_set_errno'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686
-w64-mingw32/include/stddef.h:21: error: expected constructor, destruc
tor, or type conversion before '_get_errno'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686
-w64-mingw32/include/stddef.h:26: error: expected initializer before '
__threadhandle'
In file included from helloworld.c:1:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:191: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:202: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:206: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:209: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:210: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:289: error: expected constructor, destructor, or type conv
ersion before 'fread'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:290: error: expected constructor, destructor, or type conv
ersion before 'fwrite'
In file included from helloworld.c:1:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:438: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:442: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:446: error: expected constructor, destructor, or type conv
ersion before 'fgetwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:447: error: expected constructor, destructor, or type conv
ersion before 'fputwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:448: error: expected constructor, destructor, or type conv
ersion before 'ungetwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:453: error: expected constructor, destructor, or type conv
ersion before 'getwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:454: error: expected constructor, destructor, or type conv
ersion before 'getwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:456: error: expected constructor, destructor, or type conv
ersion before 'putwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:458: error: expected constructor, destructor, or type conv
ersion before 'putwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:472: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:474: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:496: error: expected constructor, destructor, or type conv
ersion before '_fgetwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:497: error: expected constructor, destructor, or type conv
ersion before '_fputwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:502: error: expected constructor, destructor, or type conv
ersion before 'fgetwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:503: error: expected constructor, destructor, or type conv
ersion before 'fputwchar'
【问题讨论】:
-
看起来好像 stddef.h 没有正确解析。 size_t 是未知的,从而导致各种后续错误。也许DEVC ++设置了一个影响gcc的环境变量?参照。 gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html,或者相反,mingw 的 gcc 必须缺少一个。
-
谢谢,我让它工作了,我卸载了 devC++,然后重新安装了 mincw devc++ 一定与某些东西冲突
标签: c compilation mingw