user1417815
user1417815

Reputation: 455

Specify the platform using #ifdefs

To handle platform specific code between Mac and Windows, WIN32 and APPLE are the terms to use, right?

So, thw code would look like this:

#ifdef _WIN32
    // Windows code
#endif
#ifdef __APPLE__
    // Mac code
#endif

What about Linux ?

How can i do that for all three? right

Upvotes: 4

Views: 207

Answers (1)

P.P
P.P

Reputation: 121407

It's similar:

#ifdef __linux__
    // Linux code
#endif

Since you are going to have either one of these three defined at a time, this should be ok for all three.

List of defines.

Upvotes: 6

Related Questions