Discussion:
crash on macro concat
(too old to reply)
David
2017-04-06 03:27:28 UTC
Permalink
#define CONCAT_I(s1,s2) s1##s2
#define CONCAT(s1,s2) CONCAT_I(s1,s2)

#define SECOND_PARAM

#define TEMPLATE(s1) CONCAT(s1, SECOND_PARAM)

TEMPLATE(whatever)
Paul S. Person
2017-04-06 16:28:48 UTC
Permalink
Post by David
#define CONCAT_I(s1,s2) s1##s2
#define CONCAT(s1,s2) CONCAT_I(s1,s2)
#define SECOND_PARAM
#define TEMPLATE(s1) CONCAT(s1, SECOND_PARAM)
TEMPLATE(whatever)
I'm not very good with complicated #define macros.

What happens if you give SECOND_PARAM a value?

Which one is causing the crash?
--
"Nature must be explained in
her own terms through
the experience of our senses."
Hans-Bernhard Bröker
2017-04-06 16:57:13 UTC
Permalink
Post by David
#define CONCAT_I(s1,s2) s1##s2
#define CONCAT(s1,s2) CONCAT_I(s1,s2)
#define SECOND_PARAM
#define TEMPLATE(s1) CONCAT(s1, SECOND_PARAM)
TEMPLATE(whatever)
No crash.
Brian Havard
2017-04-21 05:12:51 UTC
Permalink
Post by David
#define CONCAT_I(s1,s2) s1##s2
#define CONCAT(s1,s2) CONCAT_I(s1,s2)
#define SECOND_PARAM
#define TEMPLATE(s1) CONCAT(s1, SECOND_PARAM)
TEMPLATE(whatever)
I can confirm that this crashes the C++ compiler, wpp386 in both 1.9 and
2.0, although my 2.0 install is from April 2015, not sure if there's
anything newer.

The C compiler, wcc386, doesn't crash though.

Giving SECOND_PARAM a value stops the crash.

Commenting out "TEMPLATE(whatever)" also stops the crash.

Loading...