Article View: gnu.gcc.help
Article #52193CPP macro expansion, a bug or a feature ??
From: Klaus Kaempf
Date: Mon, 18 Jan 1993 12:02
Date: Mon, 18 Jan 1993 12:02
32 lines
1793 bytes
1793 bytes
Hi there !
This one hit me rather badly over the weekend, now is this a bug or
a feature of GCC 2.3.3 ??
The expansion of SINGLE qouted macro arguments differs between sun-cc
(or gcc with -traditional set) and gcc !
For example most ioctl calls in SunOS 4.x are implemented with the following
macro:
#define _IOR(x,y,t) (_IOC_OUT|((sizeof(t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)
^ ^^^
The marked parameter is expanded differently when compiling with and without
'-traditional'. This behaviour might be correct, however Sun includes
(especially the macro shown) depend on the expansion of single-qouted
parameters. According to K&R 2nd ed. (page 230):
'... each argument is substituted for each unquoted occurence of the
corresponding parameters identifier ...'. Now what does 'unqouted' mean,
single quotes (') or double quotes (") or both (this is what GCC implements)
???
Puzzled,
Klaus
--
Klaus Kaempf E-Mail: kkaempf@didymus.rmi.de
Jakobstr. 181 Fax: 0241-403407
D-5100 Aachen Voice: 0241-403446
Technical Details
Message-ID:
<C11tGB.J38@didymus.rmi.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!gmd.de!urmel.informatik.rwth-aachen.de!infoac.rmi.de!didymus!kkaempfShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,b6c0bece18c82023,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-01-18 04:02:34 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!gmd.de!urmel.informatik.rwth-aachen.de!infoac.rmi.de!didymus!kkaempf From: kkaempf@didymus.rmi.de (Klaus Kaempf) Subject: CPP macro expansion, a bug or a feature ?? Message-ID: <C11tGB.J38@didymus.rmi.de> Summary: More to 'fixincludes' in SunOS 4.x include files ? Keywords: CPP ANSI Macro expansion Quote Organization: Klaus Kaempf Softwareentwicklung Date: Mon, 18 Jan 1993 12:02:34 GMT Lines: 33