|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - preprocessor bug and woes
This report documents 2 bugs and laments a problem I
have been unable to solve using the DMC compiler.
Bug #1. Given this program:
========================================================
#define PASS_THRU(x) x
#define NN() PASS_THRU(name_) ## PASS_THRU(__LI ## NE__)
int NN();
int NN();
========================================================
the DMC compiler chokes thusly:
> sc -c pp.cpp
int NN();
^
pp.cpp(4) : Error: 'name_PASS_THRU' is already defined
--- errorlevel 1
I believe that both operands of the ## paste operator
are supposed to be evaluated prior to the paste. The
DMC compiler appears to evaluate the two sides in a
dissymmetric manner.
For example, Microsoft's preprocessor converts it properly:
> cl /E pp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 8.00c
Copyright (c) Microsoft Corp 1984-1993. All rights reserved.
#line 1 "pp.cpp"
int name_3;
int name_4;
Bug #2. I have been been unable to get SC.exe to show
me the preprocessed form of any code. Its help claims
that invoking it with a -e option will "show results of
preprocessor", but that option does not cause anything
more to show up on stdout or in any likely directory.
Lament:
I am trying to create some kind of build time assert
facility for DMC. I used to use something like
#define BuildAssert(condition) \
extern char _dummyAssert[ (condition)? 1 : -1 ]
but DMC happily compiles this with a negative integer
as the array size. I can define a template and its
specialization that will fail when instantiated upon
a false argument, but I have completely struck out
trying to define a macro to instantiate objects that
have different names depending on the source line
in which the macro is expanded. (Hence my failed
effort leading to the above bug report.)
--
-Larry Brasfield
(address munged, s/sn/h/ to reply)
Aug 12 2002
Larry Brasfield wrote: Aug 12 2002
|