autc04 / Retro68

a gcc-based cross-compiler for classic 68K and PPC Macintoshes
GNU General Public License v3.0
548 stars 54 forks source link

Add a preprocessor macro to detect Retro68 #209

Closed johnsonjh closed 5 months ago

johnsonjh commented 1 year ago

It would be nice to have __RETRO68__ defined. Or maybe__Retro68__?

Perhaps, if built with Multiversal Interfaces, we could also define __MULTIVERSAL__, and with Universal Interfaces, we could define __UNIVERSAL__ or something similar?

This will help greatly to make programs easily cross-platform.

Right now, the best thing I've found to detect Retro68 would be something like:

#if defined(__GNUC__) && defined(pascal) && \
    ((defined(__embedded__) && defined(__m68k__)) || \
      (defined(__ppc__) && defined(__pixel)))
# define __RETRO68__ 1
#endif

This is hacky and brittle, so something official would be welcome.

Edit: Would it also make sense to also define something based on the target OS, like _SYSTEM_6, etc?

agoode commented 6 months ago

I attached a pull request, it looks like historical compilers used macintosh and/or Macintosh, so I suggest that.