QT and SDL2 funtime

Hi all,
I found a “funny” error when mixing a Qt and a SLD2 application, I’m
reporting it here for documenting the problem in case someone runs
into this again, for asking for an alternative solution than mine and
of course for the lulz, .

At compile time SDL will error out saying “error: SDL for Mac OS X
only supports deploying on 10.5 and above.” even though you correctly
set your sysroot, your MACOSX_DEPLOYMENT_TARGET and your
-mmacosx-version-min.

After half an hour of wtf-ing I found the problem in one of the Qt
headers in which this will happen

ifdef MAC_OS_X_VERSION_MIN_REQUIRED

undef MAC_OS_X_VERSION_MIN_REQUIRED

endif

define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4

So yeah, the MAC_OS_X_VERSION_MIN_REQUIRED macro will be hijacked to
10.4 and then it will be checked by SDL which will then scream in
agony.

I had to guard-check every SDL header before including but this is far
from ideal, hardcoding the minimum OS X version number. Does anyone
have a better suggestion?
Cheers,
Vittorio

2013/12/6 Vittorio Giovara <vittorio.giovara at gmail.com>

Hi all,
I found a “funny” error when mixing a Qt and a SLD2 application, I’m
reporting it here for documenting the problem in case someone runs
into this again, for asking for an alternative solution than mine and
of course for the lulz, .

At compile time SDL will error out saying “error: SDL for Mac OS X
only supports deploying on 10.5 and above.” even though you correctly
set your sysroot, your MACOSX_DEPLOYMENT_TARGET and your
-mmacosx-version-min.

After half an hour of wtf-ing I found the problem in one of the Qt
headers in which this will happen

ifdef MAC_OS_X_VERSION_MIN_REQUIRED

undef MAC_OS_X_VERSION_MIN_REQUIRED

endif

define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4

So yeah, the MAC_OS_X_VERSION_MIN_REQUIRED macro will be hijacked to
10.4 and then it will be checked by SDL which will then scream in
agony.

I had to guard-check every SDL header before including but this is far
from ideal, hardcoding the minimum OS X version number. Does anyone
have a better suggestion?
Cheers,
Vittorio

Hm, would it help if you just stuck to always including any SDL headers
first?

Why not add SDL2_MAC_OS_X_VERSION_MIN_REQUIRED to the SDL2 sources and
update any docs to say to use that? Leave the existing macro so it doesn’t
break existing apps. Aside from possibly having to update other macros for
consistency, it would guarantee that conflicts like that will not occur in
the future.

Do you have a small example you can share of mixing SDL2 and Qt? I use Qt
quite a bit but haven’t had time to try mixing the two when it comes to the
graphics. I’m sure it would be useful to others too.

Message-ID:
<CAK0i_72Lp6whusz1FfbSOeGDxeNU9rbPXTQYueTAGchjH8BOTA at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”

2013/12/6 Vittorio Giovara <@Vittorio_Giovara>

Hi all,
I found a “funny” error when mixing a Qt and a SLD2 application, I’m
reporting it here for documenting the problem in case someone runs
into this again, for asking for an alternative solution than mine and
of course for the lulz, .

At compile time SDL will error out saying “error: SDL for Mac OS X
only supports deploying on 10.5 and above.” even though you correctly
set your sysroot, your MACOSX_DEPLOYMENT_TARGET and your
-mmacosx-version-min.

After half an hour of wtf-ing I found the problem in one of the Qt
headers in which this will happen

ifdef MAC_OS_X_VERSION_MIN_REQUIRED

undef MAC_OS_X_VERSION_MIN_REQUIRED

endif

define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4

So yeah, the MAC_OS_X_VERSION_MIN_REQUIRED macro will be hijacked to
10.4 and then it will be checked by SDL which will then scream in
agony.

I had to guard-check every SDL header before including but this is far
from ideal, hardcoding the minimum OS X version number. Does anyone
have a better suggestion?
Cheers,
Vittorio

Hm, would it help if you just stuck to always including any SDL headers
first?

Unfortunately that would work only for a very tight controlled
environment, if any SDL header is included in another header it might
be easily included by another source file which screw the order up.

Vittorio> Date: Fri, 6 Dec 2013 01:15:56 +0100

From: Jonas Kulla
To: SDL Development List
Subject: Re: [SDL] QT and SDL2 funtime

Message-ID:
<CABZKpPDeU02MsdJXmTUgNzZFOWJkV260uY7f_TavCuwcZoRgmQ at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”

Why not add SDL2_MAC_OS_X_VERSION_MIN_REQUIRED to the SDL2 sources and
update any docs to say to use that? Leave the existing macro so it doesn’t
break existing apps. Aside from possibly having to update other macros for
consistency, it would guarantee that conflicts like that will not occur in
the future.

Do you have a small example you can share of mixing SDL2 and Qt? I use Qt
quite a bit but haven’t had time to try mixing the two when it comes to the
graphics. I’m sure it would be useful to others too.

I have an example, but it’s not small, you may download the hedgewars
sources under the sdl2transition branch here
https://code.google.com/p/hedgewars/source/list?name=sdl2transition

Vittorio> Date: Fri, 6 Dec 2013 01:13:40 -0600

From: Jonathan Greig
To: SDL Development List
Subject: Re: [SDL] QT and SDL2 funtime

Why not add SDL2_MAC_OS_X_VERSION_MIN_REQUIRED to the SDL2 sources and update any docs to say to use that? Leave the existing macro so it doesn’t break existing apps. Aside from possibly having to update other macros for consistency, it would guarantee that conflicts like that will not occur in the future.

MAC_OS_X_VERSION_MIN_REQUIRED is actually not defined by SDL2, it comes from the Xcode toolchain. It?s the deployment target specified by the clang command line.

  • J?rgen.On Dec 5, 2013, at 11:13 PM, Jonathan Greig <redteam316 at gmail.com<mailto:redteam316 at gmail.com>> wrote: