[Bug preprocessor/13046] New: cannot use #ifdef __APPLE__ on Darwin

n8gray at caltech dot edu gcc-bugzilla@gcc.gnu.org
Fri Nov 14 03:18:00 GMT 2003


Apologies if this is an Apple bug and not a GCC bug.

[n8gray@golux tmp]$ cpp --version
cpp (GCC) 3.3 20030304 (Apple Computer, Inc. build 1495)
[n8gray@golux tmp]$ uname -a
Darwin golux 7.0.0 Darwin Kernel Version 7.0.0: Wed Sep 24 15:48:39 PDT 2003; root:xnu/xnu
-517.obj~1/RELEASE_PPC  Power Macintosh powerpc

This code (adapted from /usr/include/ppc/param.h on a Mac OS X 10.3 install) causes CPP to do 
strange things:
#ifdef __APPLE__
#warning Defining two-argument macros
#define  btodb(bytes, devBlockSize) ((unsigned)(bytes) / devBlockSize)
#define  dbtob(db, devBlockSize)  ((unsigned)(db) * devBlockSize)
#else
#warning Defining one-argument macros
#define	btodb(bytes)  ((unsigned)(bytes) >> DEV_BSHIFT)
#define	dbtob(db)  ((unsigned)(db) << DEV_BSHIFT)
#endif

This is the output (eliding many blank lines):
[n8gray@golux tmp]$ cpp param.h
# 1 "param.h"
#pragma GCC set_debug_pwd "/Users/n8gray/tmp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "param.h"
param.h:4: warning: #warning Defining two-argument macros 
param.h:13: macro "btodb" requires 2 arguments, but only 1 given
param.h:14: macro "dbtob" requires 2 arguments, but only 1 given
# 17 "param.h"

Using using the -undef option restores the expected behavior, as does using cpp from 2.95.2.  
Other symbols besides __APPLE__ work ok.

-- 
           Summary: cannot use #ifdef __APPLE__ on Darwin
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: n8gray at caltech dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13046



More information about the Gcc-bugs mailing list