You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 [email protected] on 3 Jun 2011 at 6:34
The text was updated successfully, but these errors were encountered:
Just ran into this as well.
I don't know how it works in C, but in C++ `#` is a preprocessor directive
exactly when it is either the first nonwhitespace character in the source file
or is preceded by whitespace containing a newline.
Reference: C++ working draft N3242, "Preprocessing Directives"
[http://www.open-std.org/jtc1/sc22/wg21/]
Related to this issue, I don't know why #include/define/etc are marked as
comments. I think that C-like languages should have hashComments=false. You can
fix this issue modifying prettify.js source code. Search for:
registerLangHandler(sourceDecorator({
'keywords': CPP_KEYWORDS,
'hashComments': false, // This is true in the official release
'cStyleComments': true,
'types': C_TYPES
}), ['c', 'cc', 'cpp', 'cxx', 'cyc', 'm']);
I've attached a patch to fix this issue.
Original comment by davidcapello on 13 Dec 2013 at 7:42
Original issue reported on code.google.com by
[email protected]
on 3 Jun 2011 at 6:34The text was updated successfully, but these errors were encountered: