c ++ #ifdef Mac OS X问题 [英] c++ #ifdef Mac OS X question
问题描述
我是C ++的新手。我目前正在开展一个小组项目,我们希望使我们的课程与实验室计算机(Windows)和我的计算机(Mac OS X)兼容。
I am fairly new to C++. I am currently working on a group project and we want to make our classes compatible with both the lab computers (Windows) and my computer (Mac OS X).
这是我们在文件顶部放置的:
Here is what we have been putting at the top of our files:
#ifdef TARGET_OS_X
# include <GLUT/glut.h>
# include <OpenGL/OpenGL.h>
#elif defined _WIN32 || defined _WIN64
# include <GL\glut.h>
#endif
我意识到这个问题已经被问过,但我的搜索一直给我冲突的答案,如_MAC,TARGET_MAC_OS,MACINTOSH等。什么是当前和正确的声明放在#ifdef语句,使这与Mac兼容?现在它不工作。
I realize this question has been asked before but my searches have been giving me conflicting answers such as "_MAC", "TARGET_MAC_OS", "MACINTOSH", etc. What is the current and correct declaration to put in the #ifdef statement to make this compatible with Mac? Right now it is not working.
谢谢!
推荐答案
http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor/5920028#5920028\">此答案:
According to this answer:
#ifdef __APPLE__
#include "TargetConditionals.h"
#ifdef TARGET_OS_IPHONE
// iOS
#elif TARGET_IPHONE_SIMULATOR
// iOS Simulator
#elif TARGET_OS_MAC
// Other kinds of Mac OS
#else
// Unsupported platform
#endif
#endif
简而言之:
#ifdef __APPLE__
#include "TargetConditionals.h"
#ifdef TARGET_OS_MAC
#include <GLUT/glut.h>
#include <OpenGL/OpenGL.h>
#endif
#elif defined _WIN32 || defined _WIN64
#include <GL\glut.h>
#endif
这篇关于c ++ #ifdef Mac OS X问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!