Skip to content

C macro Stringizing operator not recognized #157

@GoogleCodeExporter

Description

@GoogleCodeExporter
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 &lt; 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 &lt; limit &amp;&amp; out == in + 1) {\
    in = in &lt;&lt; 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.com on 3 Jun 2011 at 6:34

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions