Believe me, I am the world's biggest fan of static const as opposed to
#define. I almost never use #define in my own work. I don't even like #ifdef
and its cohorts -- who needs a second "layer" of program logic to debug?
Except where performance is a big issue, or where a particular line of code
will not compile on a particular platform, I like to take the #define
symbols that we are stuck with (like versions and platforms) and assign them
to static const bool's that can be tested with ordinary if's so the logic is
"single-layer."
> static const shows up in XREF listings and even better shows up in
debuggers
And better yet has a scope (other than "from here to end of file" -- or
worse, if in a .h, "from here to the end of any file you #include me in,
plus any *other* .h files you decide to #include after me").
#define symbols can produce the most bizarre of error messages:
// in some obscure .h file:
#define foo some complex thing of some sort
// later in some file, blissfully unaware of foo's existence
class foo { ...
You will get error messages on class foo that will have you scratching your
head for a couple of hours.
Nonetheless, I have reasons for asking the question that I did; reasons that
I can't share in this venue at this time.
Charles
-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf
Of David Crayford
Sent: Tuesday, February 14, 2012 7:27 PM
To: [email protected]
Subject: Re: Any way to get the XLC compiler to list all #define symbols?
On 15/02/2012 2:11 AM, Charles Mills wrote:
> Does anyone know of a way to get the XLC compiler to list all of the
> #define symbols that are in effect? XREF and ATTR list all ordinary
> symbols. There are several ways of course of determining the define
> "state" of any particular #define symbol. But does anyone know of an
> option or a "trick" to get a list of all of them?
Charles,
Unfortunately I don't know of any tricks as the compiler substitutes #define
constants when you compile.
IIRC you are coding in C++. If that's the case then #define was deprecated
long ago in favour of static const.
static const shows up in XREF listings and even better shows up in
debuggers.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN