We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 223

Summary: SDL_rwops tries Mac paths, even on Mac OS X
Product: SDL Reporter: Anders F Bj <afb>
Component: fileAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 1.2   
Hardware: PowerPC   
OS: Mac OS X (All)   
Bug Depends on:    
Bug Blocks: 53    
Attachments: SDL12-rwops-macosx.patch

Description Anders F Bj 2006-05-09 17:52:45 UTC
Sometimes the "build system" gets confused and defines
BOTH of __MACOS__ and __MACOSX__, but this still means
that we are on Mac OS X (and not building for Mac OS 9)

Especially it does *not* mean messing paths with colons.
Comment 1 Anders F Bj 2006-05-09 17:53:21 UTC
Created attachment 120 [details]
SDL12-rwops-macosx.patch
Comment 2 Sam Lantinga 2006-05-10 01:12:10 UTC
Under what conditions are both __MACOS__ and __MACOSX__ defined?  Should we create a new identifier, e.g. __CARBON__?
Comment 3 Anders F Bj 2006-05-10 02:41:58 UTC
CodeWarrior projects, on Mac OS X. (Carbon Mach-O target)
It defines "macintosh", which in turn triggers __MACOS__

I think this was the only location where it mattered,
so I'm not sure if whether it should be revised or not ?
Comment 4 Sam Lantinga 2006-05-10 03:09:20 UTC
(In reply to comment #3)
I believe that __MACOS__ is meant to refer to MacOS Classic, and __MACOSX__ is meant to refer to Mac OS X.  Places in the SDL code which need to be different based on the target API should use the TARGET_API_MAC_* defines.

I've checked in a change that should make sure __MACOS__ is only defined on MacOS Classic.
Comment 5 Anders F Bj 2006-05-10 03:27:05 UTC
Okay, once all the changes are in the Subversion I will try to start out fresh and import (from XML) and build the CodeWarrior projects with the new code, see if I got all of those little local code changes migrated from my old CVS sandbox...

I'm fine with using __MACOS__ for Mac OS 9, and __MACOSX__ for Mac OS X builds.
(even if the Mac OS 9/CFM builds work on Mac OS X too, that's beside the point)
And you are right that TARGET_API_MAC_OS8 and TARGET_API_MAC_CARBON are better. 

So for the CW Carbon targets: CFM => __MACOS__, Mach-O ==> __MACOSX__. (OK.)
Comment 6 Sam Lantinga 2006-05-10 03:32:19 UTC
Everything should be set up in subversion.  I've updated the snapshots, as well.
Comment 7 Anders F Bj 2006-05-10 14:12:28 UTC
The macro rearrangement in SVN didn't work for me (Comment #4)

It is now including SDL_config_macos.h in the Mach-O Carbon targets,
which makes them fail to compile as it is redeclaring int32_t, etc...

Tried adding "#undef macintosh" to the prefix, but it didn't help.
Comment 8 Sam Lantinga 2006-05-10 23:22:52 UTC
(In reply to comment #7)
> The macro rearrangement in SVN didn't work for me (Comment #4)
> 
> It is now including SDL_config_macos.h in the Mach-O Carbon targets,
> which makes them fail to compile as it is redeclaring int32_t, etc...
> 
> Tried adding "#undef macintosh" to the prefix, but it didn't help.

Patch suggestions welcome...
Comment 9 Anders F Bj 2006-05-11 02:51:47 UTC
As a workaround, you could switch back to the previous "platform" header

I think these two lines in rwops were the only ones that failed anyway ?
Comment 10 Sam Lantinga 2006-05-11 04:22:31 UTC
(In reply to comment #9)
> As a workaround, you could switch back to the previous "platform" header

I'd rather not, it seems very wrong to me to have both __MACOS__ and __MACOSX__ defined.
Ideally, we'd be able to distinguish whether or not we're building on MacOS Classic or Mac OS X, and set the correct define, and then use TARGET_API_MAC* to distinguish between the target ABI.

Anyway, please open this issue as a new bug, with the description of what needs to be done to fix it.
Thanks!

Comment 11 Anders F Bj 2006-05-11 04:35:07 UTC
I agree that it is wrong to have both defined, but that's how it ends up.

Actually I thought that "def macintosh" was a pretty good tell-tale for
Mac OS 9, and "defined(__APPLE__) && defined(__MACH__)" for Mac OS X ?
But it seems that things aren't so simple. CodeWarrior seems to define
"macintosh" even when compiling Mach-O (while GCC or Xcode does *not*)
And the other two basically just specify Apple OS with Mach-O binaries,
which could just as well be OpenDarwin or something (i.e. not Mac OS X)


The easy and lazy way out is to require the user to define the platform,
but I think we can still use some heuristic like the current to "guess" ?
(somewhat similar to SDL_config.h, as it has to come from *somewhere*
whether it is the user modifying a default file, or autotools guessing)
Comment 12 Anders F Bj 2006-05-11 04:50:13 UTC
Strange, now when I double-checked with two new "blank" CW projects:

CFM does define "macintosh" (like it should) but
Mach-O does not define "macintosh" (also correct)

So I wonder what could possibly have gone wrong in SDL_platform.h ?!?


Will do some experiments with this later, and open as a new "bug".

(the main idea is still: CFM ==> __MACOS__, Mach-O ==> __MACOSX__
and preferrably only one of these defines should ever be defined)