lotus

previous page: 10.4: What is dmake?
  
page up: comp.sys.apple2. gno FAQ
  
next page: 10.6: When I'm using the new header files (post-v2.0.4), sometimes ORCA/Ccan't find my header files. Why?

10.5: What macros should I be using for conditional compilation?




Description

This article is from the Apple II GNO FAQ, by Devin Reade with numerous contributions by others.

10.5: What macros should I be using for conditional compilation?

    A#10.5:	There are four general areas where certain "standard" macros
are used ("standard" is quoted because only those explicitly
annotated correspond to ISO/ANSI or other standards).  Where
the macros aren't predefined by current compilers, they should
be defined in source, header, or makefiles when necessary:

- Architecture:
	These macros tend to be lower case with double leading-
	or trailing-underscores, such as "__sun4__" or "__parisc__".

	No IIgs compilers currently predefine an architecture,
	but "__appleiigs__" is recommended for Apple IIgs
	specific code.

- Operating System:
	These macros tend to be upper case and may or may not
	use underscores.  Examples are "_AIX" and "SunOS".

	No IIgs compilers currently predefine an os macro,
	but "__GNO__" is recommended for GNO-specific code.

- Compiler:
	These macros tend to be upper case and may or may not
	use underscores.  Examples are "__LCC__" and "__GNUC__".

	ORCA/C predefines "__ORCAC__".  APW/C predefines "APW".

- Language and other standards:
	The "__STDC__" macro may be used for determining ISO/ANSI C
	compliance.  It is the responsibility of the compiler to
	define (or not define) this macro appropriately.

	If "_POSIX_SOURCE" source is defined, the source may
	be written with the assumption that all symbols defined
	by POSIX Standard 1003.1 are available in the environment.
	This symbol is expected to be defined by the user as
	necessary.  GNO isn't yet POSIX compliant, but it's getting
	there.

	If "_BSD_SOURCE" is defined, all symbols are expected to
	be 4.3BSD compliant.  This implies "_POSIX_SOURCE".  Again,
	GNO isn't there yet but it's progressing.

	"KERNEL" is defined when building the GNO kernel.  You will
	see this macro in the GNO header files, but you should not
	define it.

	"__cplusplus" is predefined by C++ compilers, of which there
	are none for the IIgs.  It is the responsibility of the
	compiler to define (or not define) this macro appropriately.
	Explanation of this macro was given since you occasionally
	see it in GNO header files ...

Other macros are defined either by the compiler or in header files,
but these are the main ones for user code conditional compilation.
See the relevant documentation (compiler manual, ISO/ANSI or POSIX
standards, GS/OS reference manual) for more details.
    

 

Continue to:













TOP
previous page: 10.4: What is dmake?
  
page up: comp.sys.apple2. gno FAQ
  
next page: 10.6: When I'm using the new header files (post-v2.0.4), sometimes ORCA/Ccan't find my header files. Why?