Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use -Wall option on gcc/g++ and turn off the multi line comments warnings?

Tags:

gcc

warnings

Like the title, how do I use -Wall option on gcc/g++ and turn off the multi line comments warnings?

The comment look like that:

// Comment starts here \
// and end here (the // at the begging is not necessary)
like image 834
RSFalcon7 Avatar asked Dec 27 '22 11:12

RSFalcon7


2 Answers

You could use /* .. */ for the multiline comment.

    /* foo bar comment
       lala blah
    */

Edit:

I found a solution in another post here: How can I hide "defined but not used" warnings in GCC?

If you add the option -Wno-comment the warning is gone.

    gcc -Wall -Wno-comment test.c -o test

Its also explained here: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

best wishes, Matthias

like image 72
Matthias Avatar answered Dec 28 '22 23:12

Matthias


The GCC warnings are documented here: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

Specifically, you're looking for:

-Wcomment

Warn whenever a comment-start sequence /*' appears in a/*' comment, or whenever a Backslash-Newline appears in a `//' comment. This warning is enabled by -Wall.

So to turn that warning off, you should be able to use -Wno-comment.

like image 43
Andy Lester Avatar answered Dec 28 '22 23:12

Andy Lester