I tracked down a programming error on my part to the fact that I had
a nested comment. I would have thought that the compiler should warn
me about that. Then I found this:
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html#SEC8
-Wcomment
Warn whenever a comment-start sequence /*' appears in a
/*’
comment, or whenever a Backslash-Newline appears in a `//’ comment.
So I tried to add this to my Makefile. But qcc seems to just ignore it.
I tried adding:
-Wcomment
-Wc,-Wcomment
“-Wc.-Wcomment”
What is the correct way to turn on this warning?
Bill Caroselli <qtps@earthlink.net> wrote:
So I tried to add this to my Makefile. But qcc seems to just ignore it.
I tried adding:
-Wcomment
-Wc,-Wcomment
“-Wc.-Wcomment”
What is the correct way to turn on this warning?
You’re telling the wrong compiler phase - the preprocessor is responsible
for stripping comments, so it’s the one issuing the warning. Try:
-Wp,-Wcomment
–
Brian Stecher (bstecher@qnx.com) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8
bstecher@qnx.com wrote:
bqc > Bill Caroselli <qtps@earthlink.net> wrote:
So I tried to add this to my Makefile. But qcc seems to just ignore it.
I tried adding:
-Wcomment
-Wc,-Wcomment
“-Wc.-Wcomment”
What is the correct way to turn on this warning?
bqc > You’re telling the wrong compiler phase - the preprocessor is responsible
bqc > for stripping comments, so it’s the one issuing the warning. Try:
bqc > -Wp,-Wcomment
Thanks Brian.
You were right and that was embarassing!
Just one last comment. I understand that someone MAY want to comment
out a large section of code and intentionlly use block comments around
other comments. But I think this should always be flagged as a
warning.
Personally when I need to comment out large sections of code that may
also include comments I use:
#ifdef DONT_COMPILE
… . .
#endif
When trying to re-implement the commented out code it is a lot easier
to find DONT_COMPILE than to search for “/" . . . "/”.