I'm wondering why you turn on this warning. Note that it's not even
enabled by -Wall.
IMHO, this warning is just too noise for normal C++ code and not worth
it. See http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01050.html for
an interesting discussion on it.
Please see http://code.google.com/p/googletest/wiki/FAQ?ts=1292438732&updated=FAQ#I'm_getting_warnings_when_compiling_Google_Test.__Would_you,
which I just wrote. Since this warning is rarely used, and fixing it
makes Google Test's code more complex, I'm reluctant to fix it. Could
you disable the warning or use -isystem? Thanks,
--
Zhanyong
Thanks for the link. Although most of declarations in C++ are in
scope, C++ remains a super set of C, so if it makes sense for C so
does it for C++. I agree with Ian Lance Taylor.
In some rare cases (and I think Google Test is a rare case), people
write tricky code using a lot of macros and templates leading to be
border line with usual programming patterns. Warnings not included in
-Wall (or even -Wextra?) are convenient for more "conventional" code.
Thanks for the FAQ extension and for -isystem tips. I did not know it.
Actually, it solves part of the problem. Google Test provides macros
that expand code in the source test file. Thus, this code does not
have the special treatment that -isystem gives. FYI, there are issues
with -Wswitch-default and -Wswitch-enum too and probably even more.
But it is an endless list, I think.
I understand perfectly, that you cannot possibly handle all the
combinations of compilers x warning-flags without making the code even
more complex than it is already.
I will disable those flags for the test.
Thanks for your time.
--
Nicolas Desprès
FYI
I'm not saying that the warning doesn't make sense for C++. I'm
saying that it's way too noisy for C++ that it's not worth it. It may
uncover some bugs, but it also generates a lot of work to bring the
code into compliance, which means lost productivity. You have to
weigh the benefit against the cost. My hunch is that the cost is
greater than the benefit in most C++ code bases.
There is a reason why the company Ian Lance Taylor works for doesn't
use this flag. ;-)
--
Zhanyong
When using the macro:
INSTANTIATE_TEST_CASE_P(InstantiationName,
FooTest,
::testing::Values("meeny",
"miny", "moe"));
I get a warning if I compile with -Wmissing-declarations one of my
test written with google test 1.5.0 (not google test itself):
warning: no previous declaration for
'testing::internal::ParamGenerator<const char*>
gtest_InstantiationNameFooTest_EvalGenerator_()'
Here the patch that solve the problem:
--- include/gtest/gtest-param-test.h (revision 527)
+++ include/gtest/gtest-param-test.h (working copy)
@@ -1406,6 +1406,8 @@
#define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \
::testing::internal::ParamGenerator<test_case_name::ParamType> \
+ gtest_##prefix##test_case_name##_EvalGenerator_(); \
+ ::testing::internal::ParamGenerator<test_case_name::ParamType> \
gtest_##prefix##test_case_name##_EvalGenerator_() { return
generator; } \
int gtest_##prefix##test_case_name##_dummy_ = \
::testing::UnitTest::GetInstance()-
>parameterized_test_registry(). \