zhangjl / google-glog

Automatically exported from code.google.com/p/google-glog
Other
0 stars 0 forks source link

VLOG and gcc with -pedantic #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to write code that is as compliant as possible. That's why I
always compile with -ansi and -pedantic.
But the attached program won't compile. Since LOG works as expected I'm
rather confused that it does not work with VLOG.

What steps will reproduce the problem?
1. Try compiling the attached program

I used
g++ -ansi -Wno-long-long -pedantic -I<path to glog include> -L<path to glog
lib> -lglog vlog.cc

What is the expected output? What do you see instead?
It should compile it. Bit instead you get the error
vlog.cc:11: error: ISO C++ forbids braced-groups within expressions
from g++.

What version of the product are you using? On what operating system?
I'm using version 0.3.0 on Debian Linux.
$ g++ --version
g++ (Debian 4.3.2-1.1) 4.3.2

As a workaround one can remove -pedantic.

Regards

Original issue reported on code.google.com by jens.k.mueller@gmail.com on 22 Jan 2010 at 11:05

Attachments:

GoogleCodeExporter commented 9 years ago
The macro VLOG* uses the macro VLOG_IS_ON which has a braced-group within 
expression
(http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/Statement-Exprs.html#Statement-Expr
s). I
I don't know whether it is possible to write this macro without braced-group. 
That
would fix the problem. At the moment instead of not using -pedantic one can do
__extension__ VLOG_IF(10, (0 == 1))
              << "test";
to disable pedantic warnings for the following expression.
I haven't found a gcc option to disable those warnings in general.

Original comment by jens.k.mueller@gmail.com on 25 Mar 2010 at 12:54

GoogleCodeExporter commented 9 years ago
Fixed in http://code.google.com/p/google-glog/source/detail?r=82

Thanks for your report and suggesting __extension__ !

Original comment by shinichi...@gmail.com on 28 May 2010 at 3:36