[comp.lang.c] "unix" macro on System V?

peter@aucs.UUCP (03/26/87)

Under 4.3BSD Unix there is a C preprocessor macro called "unix"
which can be used to control conditional compilation. E.g.,

    #ifdef unix
       ...do some unix dependent stuff...
    #else
       ...do some generic stuff...
    #endif

I do not have access to System V Unix. Is there such a macro under
System V (or something similar).

peter@aucs.UUCP (03/26/87)

In 4.3BSD Unix C there is a macro called "unix" which may be used to
control compilation. E.g:

    #ifdef unix
        ... do some unix dependent stuff ...
    #else
        ... do some generic stuff ...
    #endif

I do not have access to a system to test this, so I was wondering
if such a macro (or something similar) exists in System V C? Please
reply to me directly if you can.

Thanx.

Peter W. Steele

UUCP:      {seismo|watmath|utai|garfield}!dalcs!aucs!Peter
BITNET:    {Peter}@Acadia
Internet:  {Peter}%Acadia.BITNET@WISCVM.WISC.EDU
PHONEnet:  (902) 542-2201x524

edw@ius2.cs.cmu.edu.UUCP (03/29/87)

In article <318@aucs.UUCP>, peter@aucs.UUCP writes:
> In 4.3BSD Unix C there is a macro called "unix" which may be used to
> control compilation. E.g:
> 
>     #ifdef unix
>         ... do some unix dependent stuff ...
>     #else
>         ... do some generic stuff ...
>     #endif
> 


  Excuse me if I am misunderstanding your question, but conditional
compulation (#ifdef, #ifndef and #if) is or at least should be support
by every C compiler.

   example :
.
.
#ifdef DEBUG
    printf("size %d\nn",size);
#endif
.
.

 If you compile your code using -D option (cc -DDEBUG) the debugging code
will be included.  Nothing is sacred about the variable DEBUG.  You
can also do things like:

#ifndef TRUE
#define TRUE  1
#endif

where if the macro TRUE is not defined already, it will be now.
This will avoids all those anoying macro whatever is redefined messages
from the compiler.


  If your question is however, does every unix compiler automatically define
'unix' for you, I do not know.

				

-- 
					Eddie Wyatt

Those who know what's best for us-
Must rise and save us from ourselves
Quick to judge ... Quick to anger ... Slow to understand...
Ignorance and prejudice and fear [all] Walk hand in hand.
					- RUSH 

guy@gorodish.UUCP (03/29/87)

> In 4.3BSD Unix C there is a macro called "unix" which may be used to
> control compilation. E.g:
> 
> I do not have access to a system to test this, so I was wondering
> if such a macro (or something similar) exists in System V C?

Berkeley didn't invent this.  AT&T did - specifically, the people at
Bell Labs did.  It dates back to V7.  4BSD, 2BSD, V7, S3, and S5 all
have it; the reason why is that the preprocessor portion of their C
compilers is derived from the preprocessor done at the labs for V7.