在 Pelles c windows.h 中无法编译
我正在使用pelles c。当我编译此代码时:
#include <windows.h>
#include <stdio.h>
void main(void)
{
printf("Hello World");
}
我会收到此错误:
D:\Program Files\PellesC\Include\Win\basetsd.h(53): error #2001: Syntax error: expected ';' but found 'INT64'.
D:\Program Files\PellesC\Include\Win\basetsd.h(53): warning #2099: Missing type specifier; assuming 'int'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): error #2120: Redeclaration of '__int64', previously declared at D:\Program Files\PellesC\Include\Win\basetsd.h(53); expected 'int' but found 'unsigned int'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): error #2001: Syntax error: expected ';' but found 'UINT64'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): warning #2099: Missing type specifier; assuming 'int'.
D:\Program Files\PellesC\Include\Win\winnt.h(558): fatal error #1014: #error: "No target architecture".
感谢您的帮助。
I'm using pelles c. when I compile this code:
#include <windows.h>
#include <stdio.h>
void main(void)
{
printf("Hello World");
}
I get this error:
D:\Program Files\PellesC\Include\Win\basetsd.h(53): error #2001: Syntax error: expected ';' but found 'INT64'.
D:\Program Files\PellesC\Include\Win\basetsd.h(53): warning #2099: Missing type specifier; assuming 'int'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): error #2120: Redeclaration of '__int64', previously declared at D:\Program Files\PellesC\Include\Win\basetsd.h(53); expected 'int' but found 'unsigned int'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): error #2001: Syntax error: expected ';' but found 'UINT64'.
D:\Program Files\PellesC\Include\Win\basetsd.h(57): warning #2099: Missing type specifier; assuming 'int'.
D:\Program Files\PellesC\Include\Win\winnt.h(558): fatal error #1014: #error: "No target architecture".
thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了在
pellesc
中使用Windows.h
,您必须转到:In order to use
windows.h
inPellesC
you have to go to:您缺少一些其他编译器(例如 Visual Studio)总是定义的
#define
。它们提供了有关处理器架构、操作系统版本、SDK 版本等的基本信息。最好查找 Microsoft 文档以了解其编译器定义的宏并执行相同的操作。
此页面可能是一个很好的起点。
You're missing some
#define
s which other compilers (e.g. Visual Studio) always define. They provide essential information about the processor architecture, the OS version, the SDK version etc.It's probably best to look up the Microsoft documentation about what macros their compiler defines and do the same.
This page could be a good starting point.
int main(void)
而不是void main(void)
初始化您的程序return(0);
的返回语句就在最后一个括号之前。您必须包含此内容,否则您将收到语法错误,因为您的程序不知道何时停止运行。然后执行以下操作
Project
,然后向下滚动并选择“Project Options”。Compiler
选项卡,并确保Calling conv:
框已选择_cdecl
。linker
选项卡,并确保在subsystem
框中将类型设置为Console
。尝试再次构建它,看看会发生什么!
int main(void)
and notvoid main(void)
return(0);
just before your last bracket. You must include this or you will get a syntax error because your program does not know when to stop running.Then do the following
Project
then scroll down and select `Project Options.Compiler
tab and make sure that theCalling conv:
box has_cdecl
selected.linker
tab and make sure that in thesubsystem
box the type is set toConsole
.Try building it again and see what happens!