| ??? 06/19/02 19:34 Read: times |
#24637 - RE: SDCC Compiler |
I wrote:
"...never have an unterminated cpmment [sic!] (including a C++ style // comment) on the end of a #define... :-0" Donald Catto suggested: "I think you mean 'never have an unterminated /* */ comment anywhere'" That, of course, is true! But what I was really trying to say was, don't have a comment on a #define line which is not terminated on that same line; eg, #define FRED blah /* This comment is OK */
#define STUFF fleeble /* This comment is dodgy,
because the termination is on a different line!
Therefore the #define contains
an unterminated comment!
*/
"// comments at the end of #defines are fine if the preprocessor handles them intelligently. Keil certainly does" This is true. However, I have seen preprocessors which do not handle it intelligently: they include the unterminated comment as part of the definition. Then, of course, the macro expansion gives you an unterminated comment in the middle of your code - and you get all sorts of weird errors!! In fact, I think this behaviour is not only unintelligent, but actually incorrect - I believe that K&R specify that comments should be removed before macros are defined (I don't have my copy to hand at the moment). |



