COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 03-06-2017, 03:21 PM   #1
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 6,838
Default platform specific code (SOLVED)

If I want to put some code in myPlugin.cpp that only should compile for the Windows version but ignored on Mac is this the correct way ?

Code:
#ifdef __WINDOWS__
put code here
#endif // __WINDOWS__

Last edited by nofish; 03-07-2017 at 06:53 AM.
nofish is online now   Reply With Quote
Old 03-07-2017, 12:30 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,773
Default

Yeah, more or less:

Code:
#ifdef _WIN32
// Windows code goes here.
#endif

#ifdef __APPLE__
// macOS code goes here.
#endif
Tale is offline   Reply With Quote
Old 03-07-2017, 02:06 AM   #3
stw
Human being with feelings
 
Join Date: Apr 2012
Posts: 203
Default

I don't know how windows versions are handled. I just do it the other way round:
Code:
#ifdef OS_OSX

// osx code

#else

// windows code

#endif
stw is offline   Reply With Quote
Old 03-07-2017, 03:18 AM   #4
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,773
Default

Quote:
Originally Posted by stw View Post
I don't know how windows versions are handled.
When targetting Windows OS_WIN is defined.

However, those are IPlug specific (and IMHO redundant), and OP didn't mention IPlug.
Tale is offline   Reply With Quote
Old 03-07-2017, 06:26 AM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 6,838
Default

Quote:
Originally Posted by Tale View Post
OP didn't mention IPlug.
Sorry, yes, I meant using IPlug.

To clarify, this

Quote:
#ifdef _WIN32
// Windows code goes here.
#endif
would then only account for the 32 bit version of a plugin I guess ?
Anyway, I think I just go with

#ifdef OS_WIN

in my IPlug project if that's fine (the code needn't be architecture specific).
Thanks.

btw., Tale, while you're here, the PM I sent you a while ago is redundant now, have it solved.
nofish is online now   Reply With Quote
Old 03-07-2017, 06:46 AM   #6
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,315
Default

Win32 is just used to refer to the Windows API, it just happens to have 32 in the name. In IPlug, OS_WIN is defined here so you can see it just defines OS_WIN if _WIN32 is defined...

https://github.com/olilarkin/wdl-ol/...PlugOSDetect.h
snooks is offline   Reply With Quote
Old 03-07-2017, 06:53 AM   #7
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 6,838
Default

Got it, thanks.
nofish is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:26 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.