Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » Mac OS » Conditional compiling
Conditional compiling [message #51364] Fri, 15 March 2019 21:06 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

my program run under Windows and Linux. The source code is the same but there are part of the code that works only in windows.
So far I used

#ifdef PLATFORM_WIN32
// windows code
#else
// linux code
#endif

to choose what to compile. In future I need to compile different the code depending of Windows, Linux and MacOS.

I wonder which def flag will permit me to separate the Linux stuff from the MacOS one.

Thanks a lot,
Luigi
Re: Conditional compiling [message #51365 is a reply to message #51364] Fri, 15 March 2019 22:00 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
PLATFORM_OSX?
Re: Conditional compiling [message #51366 is a reply to message #51365] Fri, 15 March 2019 23:04 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1076
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

It seems that for the UI applications Mirek is using PLATFORM_COCOA. Here is part of TheIDE that creates macOS global menu (ide/idebar.cpp - line 879):
void Ide::SetMenuBar()
{
#ifdef PLATFORM_COCOA
	SetMainMenu(THISBACK(MainMenu));
	menubar.Hide();
#else
	menubar.Set(THISBACK(MainMenu));
#endif
}

However, it is only true if Cocoa back-end is enable (currently default and the most advanced one for macOS). So, you can not relay on this flag for your console applications.

In the Core/config.h file there are following platform definitions that are equal on macOS:
			#define PLATFORM_MACOS 1
			#define PLATFORM_OSX 1

The above declaration are good to check for platform in low level code that doesn't require UI elements. Currently, I would prefer PLATFORM_MACOS over PLATFORM_OSX, because it agrees with current Apple naming convention for their desktop operating system. MAC OS X naming was abandon in 2016. Also, please notice that macOS is POSIX platform, so in most non UI cases you should relay on PLATFORM_POSIX flag.

Sincerely,
Klugier


U++ - one framework to rule them all.

[Updated on: Fri, 15 March 2019 23:08]

Report message to a moderator

Re: Conditional compiling [message #51395 is a reply to message #51366] Wed, 20 March 2019 09:07 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Good explanation.

Just one clarification: I have dedicated PLATFORM_COCOA to "native" macos apps (using Cocoa as backend).

In theory, PLATFORM_OSX / PLATFORM_MACOS are active for X11 applications on Mac. Hopefully, that is not important anymore...

Mirek
Previous Topic: Problem with macOs compiling in Linux
Next Topic: Cannot compile plugin/ftp
Goto Forum:
  


Current Time: Thu Apr 18 19:06:22 CEST 2024

Total time taken to generate the page: 0.01830 seconds