minow@decvax.UUCP (Martin Minow) (05/03/84)
Doug Gwyn noted that the C preprocessor allows you to form composite tokens by using a "null" comment in the macro definition: #define token(a, b) a/**/b ... ... token(foo, bar) generates "foobar" I think this is specific to the particular implementation of the pre-processor and may not be transportable. There have been mumblings in the C standards documentation as to how #defines and comments will work, but I wouldn't count on the above hack surviving. Flames to the net -- I'm not on the committee. Martin Minow decvax!minow
dmmartindale@watcgl.UUCP (Dave Martindale) (05/03/84)
Berkeley uses this particular atrocity to form the names of the routines used to implement 4.1BSD "compatibility mode" under 4.2BSD. The C compiler is quite happy with the tokens formed in this way, but when lint is used the comments do not get deleted by the preprocessor and lint gets severe indigestion.
tim@unc.UUCP (Tim Maroney) (05/04/84)
I like the ability to form concatenated tokens, and I wish it would be added to the C preprocessor, but I don't like # define cat(a,b) a/**/b It has always been my impression that comments are lexically separators. -- Tim Maroney, The Censored Hacker mcnc!unc!tim (USENET), tim.unc@csnet-relay (ARPA) All opinions expressed herein are completely my own, so don't go assuming that anyone else at UNC feels the same way.
edhall@randvax.UUCP (05/05/84)
+ Another alternative (which is probably equally offensive): | |#define cat(a,b) a\ |b | At least this doesn't rely on the preprocessor stripping comments. But it is still likely to be non-portable. -Ed Hall decvax!randvax!edhall