RE: bad example to set to newbies on web page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So...

>> How are C++ style comments '//' ambiguous?

>     foo = bar//*comment*/4;

Which is broken, the C++ style or the C style comment?  Seems to be a matter of interpretation.  If I said "avoid comments using /* */" the ambiguity problem would also be solved.  Since both are ANSI compliant, neither has precedence over the other.

In fact, gcc emits a parsing error with the above code.  It appears that gcc (v 2.96.xx) gives precedence to the C++ style over C style comments, probably parsing tokens from left to right.

I would only say that the above syntax should be avoided.  Better yet, my preference with regard to coding style is that comment tokens be given white space separation so that they never run together with other tokens.

In the scheme of things, it hardly matters, excpept that I find it easier to make readable comments with // over /* */.

Whoopee.

Nat
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux