Fun with C
Jul. 27th, 2006 04:08 pmA fun way to make your C (C99, really) code slightly less readable:
If you need to make a multiline comment, you would typically either use the /* */ comment style or prefix each line with //, as newly defined in the C99 standard.
For example,
But the more fun way is to use a combination of the newer //-style comment combined with \.
For example:
If you use gcc with -Wall it'll complain at you, but otherwise it works perfectly fine. Yay C!
(I happened to discover this by accident when I ended a //-style comment with a :\ smiley and suddenly things broke.)
If you need to make a multiline comment, you would typically either use the /* */ comment style or prefix each line with //, as newly defined in the C99 standard.
For example,
/* This is some longer comment */ // This is also // a multiline comment
But the more fun way is to use a combination of the newer //-style comment combined with \.
For example:
// This is also a \ multiline comment \ though much less obviously \ so
If you use gcc with -Wall it'll complain at you, but otherwise it works perfectly fine. Yay C!
(I happened to discover this by accident when I ended a //-style comment with a :\ smiley and suddenly things broke.)
(no subject)
Date: 2006-07-27 11:30 pm (UTC)Point 2: Is that really less readable?
Point 3: Real men comment C code with #if 0
(no subject)
Date: 2006-07-28 12:40 am (UTC)It's not necessarily less readable, but it can make code confusing, especially if you're dumb and not using a syntax-highlighting editor (or the one you're using is broken).
(no subject)
Date: 2006-07-28 01:20 am (UTC)Bad gcc. No biscuit.
(no subject)
Date: 2006-07-28 03:12 am (UTC)// Now that's a comment that deserves an =O
(no subject)
Date: 2006-07-28 03:46 am (UTC)(no subject)
Date: 2006-07-29 03:36 am (UTC)GNU standards allow // comments in normal ol' C code, for example. You gotta say -ansi or -std=c99 to really say it's non-standard. The point still stands though... then again, I bet some people who put messages in ./configure scripts that make out to something like "GCC WILL DESTROY ALL FOREIGN CC". Nice find.
(no subject)
Date: 2006-07-28 02:09 am (UTC)