B
Ben Hetland
....in certain cituations they can be useful if not for anything else,
then at least for saving a lot of repetetetetetitititive typing.
Beyond the point of "do something better instead", I'm curious about how
the following syntactical problem can be solved. It should apply equally
to C and C++ as it mainly is a preprocessor-related problem.
I tryed to define something similar to the following example:
-------------------------------------
#define DO_DIRTYWORK \
\
#pragma warning( disable : 4995 ) /* Annoying warning */ \
\
/* Do some dirty work here (that I want to hide) */ \
\
#pragma warning( default : 4995 ) /* Warning reactivated */ \
/* finished dirty part */
-------------------------------------
The point was of course to use that DO_DIRTYWORK several places around
the sources. Its content was not really part of the main logic, but
merely a library workaround that required some lines of code injected
"everywhere". (When the library was fixed later, then maybe I could just
redefine the DO_DIRTYWORK macro as empty!)
However, this doesn't compile of course, because a prepocessor directive
needs to start as the first non-blank # on a line, which is conflicting
with the macro's end-of-line escapes (the \). Obviously, what I _wanted_
to achieve in this particular case, was to have the actual preprocessor
directives emitted from the preprocessor's first replacement (then
further preprocessed in-place where the actual code is used).
Can something like that be achieved?
How?
then at least for saving a lot of repetetetetetitititive typing.
Beyond the point of "do something better instead", I'm curious about how
the following syntactical problem can be solved. It should apply equally
to C and C++ as it mainly is a preprocessor-related problem.
I tryed to define something similar to the following example:
-------------------------------------
#define DO_DIRTYWORK \
\
#pragma warning( disable : 4995 ) /* Annoying warning */ \
\
/* Do some dirty work here (that I want to hide) */ \
\
#pragma warning( default : 4995 ) /* Warning reactivated */ \
/* finished dirty part */
-------------------------------------
The point was of course to use that DO_DIRTYWORK several places around
the sources. Its content was not really part of the main logic, but
merely a library workaround that required some lines of code injected
"everywhere". (When the library was fixed later, then maybe I could just
redefine the DO_DIRTYWORK macro as empty!)
However, this doesn't compile of course, because a prepocessor directive
needs to start as the first non-blank # on a line, which is conflicting
with the macro's end-of-line escapes (the \). Obviously, what I _wanted_
to achieve in this particular case, was to have the actual preprocessor
directives emitted from the preprocessor's first replacement (then
further preprocessed in-place where the actual code is used).
Can something like that be achieved?
How?