[cc65] Re: Macro naming

From: Jonathan Graham Harston <jgh1arcade.demon.co.uk>
Date: 2008-05-29 22:58:46
> Message-ID: <20080528170429.GA27975@trikaliotis.net>
 
Spiro Trikaliotis wrote:
> Is this really sensible?
 
Yes. How else does the source code know what it's targetted at.
 
> If you start this, you could also start for some "unusual"
> compilers like
 
Only if people want to make it rediculously difficult to work out
what predefined macros their compiler uses to specify a target.
 
> What exactly do you want to achieve? I could not understand it from your
 
I'm updating a C compiler[1] and trying to ensure that it
consistantly predefines certain macros so that source code can be
written to take advantage of that and compile differently for
different targets. It happens all the time. Look at the source for
gcc or infozip or zmodem or kermit or cZ80Tube or loads of code
that is compilable on different platforms, eg:
 
#ifdef __riscos__
  setfileattr(fn, load, exec, attr);
#elif __win32__
  writeattr(fn, mdateoff, ro);  
#elif __macos__
  filer_setinf(fn, macfdate(mdateoff));
#endif
etc...
 
My copy of gcc defines __platform__ and __cpu__, ie two
underlines, lower case, two underlines, eg __win32__ __i586__.
 
cc65 defines __PLATFORM__, ie two underlines, upper case, two
underlines, eg __APPLE2__, __BBC__.
 
So, if code wants to be compilable with both cc65 and gcc, then
code has to test for both macros:
 
#if (__ATARI__ || __atari__)
 
Either cc65 and my Small-C should use __platform__, or we behalf
should petition the gcc authors to change gcc to use __PLATFORM__.
 
Even worse, infozip source code refers to MACOS, MSDOS, UNIX,
etc., but also to __human86k__ and __IBMPC__.
 
My code uses __platform__ and __cpu__.
 
________
[1] http://mdfs.net/System/C/BBC/Small-C/v073
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
A Review of Sheffield City Council's Members' Allowances Scheme
                                  See http://mdfs.net/payreform
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri May 30 00:00:36 2008

This archive was generated by hypermail 2.1.8 : 2008-05-30 00:00:38 CEST