在 Pelles c windows.h 中无法编译

发布于 2024-10-27 12:13:23 字数 964 浏览 5 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时光磨忆 2024-11-03 12:13:23

为了在pellesc中使用Windows.h,您必须转到:

  • project -&gt;项目选项->编译器
  • 检查:启用Microsoft Extensions

In order to use windows.h in PellesC you have to go to:

  • Project -> Project Options -> Compiler
  • Check: Enable Microsoft Extensions
孤独岁月 2024-11-03 12:13:23

您缺少一些其他编译器(例如 Visual Studio)总是定义的#define。它们提供了有关处理器架构、操作系统版本、SDK 版本等的基本信息。

最好查找 Microsoft 文档以了解其编译器定义的宏并执行相同的操作。

页面可能是一个很好的起点。

You're missing some #defines 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.

嘿嘿嘿 2024-11-03 12:13:23
  1. 使用 int main(void) 而不是 void main(void) 初始化您的程序
  2. 您缺少 return(0); 的返回语句就在最后一个括号之前。您必须包含此内容,否则您将收到语法错误,因为您的程序不知道何时停止运行。

然后执行以下操作

  1. 从下拉菜单栏中选择Project,然后向下滚动并选择“Project Options”。
  2. 选择Compiler 选项卡,并确保Calling conv: 框已选择_cdecl
  3. 单击linker 选项卡,并确保在subsystem 框中将类型设置为Console

尝试再次构建它,看看会发生什么!

  1. Initialize your program by using int main(void) and not void main(void)
  2. You are missing your return statement of 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

  1. From your pull down menu bar select Project then scroll down and select `Project Options.
  2. Select the Compiler tab and make sure that the Calling conv: box has _cdecl selected.
  3. Click on the linker tab and make sure that in the subsystem box the type is set to Console.

Try building it again and see what happens!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文