When using a C macro with stringized variables, all the code after the # will
appear greyed-out as a preprocessor directive:
<pre class="lang-c prettyprint-override"><code>#define MIN(a, b) (a < b ? a
: b)
#define LARGEST_INT_TYPE unsigned long long
#define testimax(TEST_TYPE) {\
LARGEST_INT_TYPE in, out;\
size_t pow, limit;\
TEST_TYPE t;\
in = 1; out = 2; pow = 0;\
limit = MIN(sizeof(TEST_TYPE)*8,\
sizeof(LARGEST_INT_TYPE)*8);\
while (pow < limit && out == in + 1) {\
in = in << 1;\
t = (TEST_TYPE) in + 1;\
out = t;\
++pow;\
}\
if (pow == limit)\
puts( #TEST_TYPE " seems integral");\
else printf (#TEST_TYPE\
" conversion imprecise for 2^%d+1:\n"\
" in: %llu\n out: %llu\n\n", pow, in + 1, out);\
}
int main(void)
{
testimax(float);
testimax(double);
}
</code></pre>
for `puts( #TEST_TYPE " seems integral");\`, the string after `#TEST_TYPE`
should be syntax-highlighted as a string.
Don't know the version: this is from
http://stackoverflow.com/questions/6060406/using-floats-or-doubles-instead-of-in
ts/6060451#6060451 on Google Chrome 13.0.782.1 dev-m Windows.
Original issue reported on code.google.com by
stu...@testtrack4.comon 3 Jun 2011 at 6:34