Skip to main content
GameDev.net gamedev.net
🔒 Locked

Mac OS and linux programming

Started by BloodLust666 Aug 14, 2006 at 5:53 PM 7 replies 650+ views
Original Post
BloodLust666
BloodLust666
I'm using API's that a cross platform; now in my code i have #ifdef _WIN32 #include #endif and after that i would check and include files needed for linus and mac programs to run on. what defines would i check there and what includes do i include?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
one of the pages didn't work... prob. the one with the answer.. but i did find in the other ones the defines i need to check for

linus is __linus
mac os x is __APPLE__ & __MACH__
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
PhilMorton
PhilMorton
shouldnt that be __linux not __linus?

In some files you will definately need something like
#ifdef _WIN32
#include
#endif

but you should only do this in the files that REALLY NEED to use something from windows.h

If the file you're working on doesnt specifically need anything windows-specific, then dont include windows.h whatsoever.
Allways question authority......unless you're on GameDev.net, then it will hurt your rating very badly so just shut the fuck up.
BloodLust666
BloodLust666
oops, yea, that's what i meant.

but what i'm trying to get is what include files i need in order to run programs in Mac OS X and Linux.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
jpetrie
jpetrie
That depends entirely on what APIs you are using on those platforms.

It sounds like you've never written a (for example) Macintosh application before. Perhaps you should try that first? Apple's equivalent to MSDN is the Apple Developer Connection; start there. You'll probably want to look up information on the Carbon APIs, as they are the windowing/OS-level APIs you interact with from C or C++ (as opposed to Cocoa, which you access via Objective-C).

If you are using something that abstracts away the details of the windows and OS-level APIs per-platform, you probably don't need to do this as the abstracting API should take care of it for you.
BloodLust666
BloodLust666
the api's that i'm using are OpenGL, OpenIL, OpenAL, and SDL. I've researched through them on what platforms they can run on and they're pretty versitile and are able to run on Mac OS X and linux
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
markr
markr
If you are using these libraries exclusively for any platform-specific stuff, then you should not need to include windows.h at all.

Likewise, you should not need to include any other platform-specific headers.

Watch out however, as they may get included implicitly by something else then you'll end up using some function from a library which is not available on all (e.g. gettimeofday does not exist in Windows).

Mark
Ravuya
Ravuya
I generally use __APPLE__. I seem to remember SDL has a define you can use to get the current platform define in one of its headers.

For your header includes, I generally use for GL, and "SDL/SDL.h" for SDL on OS X. I don't know about OpenAL/DevIL, but I've seen other people using it. Consult the iDevGames forum's porting section.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.