|
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++ - Eliminating unused data
Are there any options that will cause dmc not to generate string constants when
they are not used? In my project, I have lots of debugging code, which is all
gone for release builds, but debugging messages are still present in final
executable. I.e. I want "Hello, world." not to be generated from the following
program(simplified).
#ifdef LOGGING
void log(const char *s)
{
printf("%s\n");
}
#else
inline void log(const char *s)
{
}
#endif
int main()
{
log("Hello, world");
return 0;
}
Aug 15 2003
Try using a macro like this
#define LOGGING 1
#ifdef LOGGING
#define TRACE printf
#else
#define TRACE 1 ? (void)0 : printf
#endif
int main(int argc, char* argv[])
{
for (int n = 0; n < argc; n++)
TRACE("Hello, world, argv[%d] = %s\n", n, argv[n]);
return 0;
}
HTH
Winfried
Aug 15 2003
In article <bhisbv$2o3i$1 digitaldaemon.com>, Winfried Mevenkamp says...Try using a macro like this Aug 18 2003
You may want to look up function-level linkage in the manual. Nicolay Haustov wrote: Aug 15 2003
In article <bhj0tt$2s1a$2 digitaldaemon.com>, Ilya Minkov says...You may want to look up function-level linkage in the manual. Aug 18 2003
|