C++ 我在哪里可以获得 Mac 的 windows.h?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26600136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 11:39:11  来源:igfitidea点击:

Where can I get windows.h for Mac?

c++cwindowsmacosopengl

提问by warship

I'm trying to compile a program on MacOSX that I originally wrote on a Windows OS. The program is a large C++ program with the OpenGL API among other things, totaling very many directories and files.

我正在尝试在 MacOSX 上编译我最初在 Windows 操作系统上编写的程序。该程序是一个带有 OpenGL API 等的大型 C++ 程序,总共包含非常多的目录和文件。

The compilation process at first had a problem with OpenGL for the Mac so I downloaded all the command line utilities of OpenGL for it to work. But as you might imagine, each C file within the OpenGL download had many preprocessors, each of which I in turn had to downloaded the dependencies for.

Mac 版的 OpenGL 最初的编译过程存在问题,因此我下载了 OpenGL 的所有命令行实用程序以使其正常工作。但是正如您想象的那样,OpenGL 下载中的每个 C 文件都有许多预处理器,而我又必须为每个预处理器下载依赖项。

However, I have remaining one critical step: I receive a fatal error saying that windows.h file is not found. This seems something inherent to the Windows system (the windows.h file is nowhere to be found in my huge list of directories for the program), and the Mac does not seem to have an equivalent for windows.h (http://cboard.cprogramming.com/c-programming/96087-windows-h-mac.html).

但是,我还剩下一个关键步骤:我收到一个致命错误,提示找不到 windows.h 文件。这似乎是 Windows 系统固有的东西(在我庞大的程序目录列表​​中找不到 windows.h 文件),而 Mac 似乎没有 windows.h 的等效文件(http://cboard .cprogramming.com/c-programming/96087-windows-h-mac.html)。

Am I out of luck trying to compile this program for the Mac or can something be salvaged?

我在为 Mac 编译这个程序时不走运还是可以挽救一些东西?

采纳答案by Andon M. Coleman

One thing you can do is create a dummy file called windows.hto satisfy the #includedirective, then track down the missing typedefs, #defines, etc. one-by-one by looking at the compiler error log.

您可以做的一件事是创建一个称为windows.h满足#include指令的虚拟文件,然后通过查看编译器错误日志逐一追踪丢失的 typedef、#defines 等。

Windows.his monolithic and includes about a hundred other Windows headers, but your program is not going to need all of those definitions. This assumes you are not using the Windows API directly, and only using simple things like DWORD. If your software is built using a framework like GLUT or GLFW that is entirely possible, but if you directly interface with WGL, you are going to have a lot of work ahead of you.

Windows.h是单一的,包括大约一百个其他 Windows 头文件,但您的程序不需要所有这些定义。这假设您没有直接使用 Windows API,而只使用简单的东西,如DWORD. 如果您的软件是使用 GLUT 或 GLFW 之类的框架构建的,这是完全可能的,但是如果您直接与 WGL 交互,那么您将有很多工作要做。

回答by SLaks

windows.his provided by the Windows SDK, and implemented by the Windows OS itself.

windows.h由 Windows SDK 提供,由 Windows 操作系统本身实现。

You need to rewrite the program to not use Windows APIs.
Good luck.

您需要重写程序以不使用 Windows API。
祝你好运。

回答by Chantola

You cannot get Windows.h for mac, it is Windows OS specific.
There are many alternatives to functions used in Windows.h on the other hand.

您无法获得适用于 Mac 的 Windows.h,它是特定于 Windows 操作系统的。
另一方面,Windows.h 中使用的函数有许多替代方法。