Specify the platform using #ifdefs

To process platform-specific code between Mac and Windows, WIN32 and APPLE are terms of use, right?

So this code will look like this:

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

What about Linux?

How can I do this for all three? to the right

+4
source share
1 answer

It looks like:

 #ifdef __linux__ // Linux code #endif 

Since you will have either one of these three given at a time, this should be good for all three.

List of definitions.

+6
source

Source: https://habr.com/ru/post/1415742/


All Articles