manpagez: man pages & more
info m4
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.1 Determining the platform

Sometimes it is desirable for an input file to know which platform m4 is running on. GNU m4 provides several macros that are predefined to expand to the empty string; checking for their existence will confirm platform details.

Optional builtin: __gnu__
Optional builtin: __os2__
Optional builtin: os2
Optional builtin: __unix__
Optional builtin: unix
Optional builtin: __windows__
Optional builtin: windows

Each of these macros is conditionally defined as needed to describe the environment of m4. If defined, each macro expands to the empty string. For now, these macros silently ignore all arguments, but in a future release of M4, they might warn if arguments are present.

When GNU extensions are in effect (that is, when you did not use the ‘-G’ option, see section Invoking m4), GNU m4 will define the macro __gnu__ to expand to the empty string.

$ m4
__gnu__
⇒
__gnu__(`ignored')
⇒
Extensions are ifdef(`__gnu__', `active', `inactive')
⇒Extensions are active
$ m4 -G
__gnu__
⇒__gnu__
__gnu__(`ignored')
⇒__gnu__(ignored)
Extensions are ifdef(`__gnu__', `active', `inactive')
⇒Extensions are inactive

On UNIX systems, GNU m4 will define __unix__ by default, or unix when the ‘-G’ option is specified.

On native Windows systems, GNU m4 will define __windows__ by default, or windows when the ‘-G’ option is specified.

On OS/2 systems, GNU m4 will define __os2__ by default, or os2 when the ‘-G’ option is specified.

If GNU m4 does not provide a platform macro for your system, please report that as a bug.

define(`provided', `0')
⇒
ifdef(`__unix__', `define(`provided', incr(provided))')
⇒
ifdef(`__windows__', `define(`provided', incr(provided))')
⇒
ifdef(`__os2__', `define(`provided', incr(provided))')
⇒
provided
⇒1

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on September 29, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.