TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Jonathan de Boyne Pollard
from: Mike Bilow
date: 1995-05-15 01:20:04
subject: #Pragma Pain!

Jonathan de Boyne Pollard wrote in a message to Mike Bilow:

  > Much of the conditional compilation in the source code is
  > intended to get around outright bugs in Watcom that are
  > still unresolved as of v10.0a.  For example, the following
  > code works under Microsoft C but not under Watcom C:
  >
  > #define ENABLE _enable
  > #define DISABLE _disable
  > #pragma intrinsic (ENABLE, DISABLE)
  >
  > However, this works under both compilers:
  >
  > #pragma intrinsic (_enable, _disable)

 JdBP> Interesting.  Are you *sure* that macro expansion is suppose to 
 JdBP> happen in #pragma directives ?  I didn't think that it was.

You can read the ANSI document two ways.  The definition of the
"#pragma" directive pretty much says that anything following it
on the same line is treated in an implementation-defined manner.  However,
the definition of the "#define" directive makes clear that its
scope includes subsequent preproccessing directives.

 JdBP> It certainly doesn't happen in other preprocessor directives, 
 JdBP> such as #define.

Of course it happens in other preprocessor directives, especially #define. 
The operation of OS2.H depends upon this.  For example, in OS2DEF.H, there
is:

   #define BOOL32    BOOL
   #define PBOOL32   PBOOL

Does the compiler expand these symbols recursively each time they are
encountered in the source, or does the compiler do it once with macro
replacement?

 JdBP> In fact the only place where macro expansion occurs in 
 JdBP> preprocessor directives that I can think of offhand is in 
 JdBP> #include. 

It also occurs in "#if", "#elif", and several others.

 JdBP> Watcom may be correct and Microsoft wrong here, you know ... 

My understanding is that Watcom considers it a bug.
 
-- Mike


---
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 323/107 150 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.