Bug: use of undeclared identifier 'FLT_MAX' missing header

1,915 views
Skip to first unread message

Benoit Daloze

unread,
Mar 1, 2014, 9:04:19 AM3/1/14
to googletes...@googlegroups.com
Hello,

Under certain conditions which are not especially easy to reproduce,
the build of a test using test (starting at r663 until at least r677) fails with:

[ 11%] Building CXX object vm/vm/test/CMakeFiles/vmtest.dir/testutils.cc.o
/usr/bin/clang++    -Wall -std=c++0x -stdlib=libc++ -I/usr/lib/c++/v1 -O3 -DNDEBUG -I/Users/benoitdaloze/git/mozart2/vm/vm/test/../main -I/Users/benoitdaloze/prefix/build/moz2-release-tmp/vm/vm/test/../main -I/Users/benoitdaloze/prefix/build/moz2-release-tmp/externals/Source/gtest -I/Users/benoitdaloze/prefix/build/moz2-release-tmp/externals/Source/gtest/include    -o CMakeFiles/vmtest.dir/testutils.cc.o -c /Users/benoitdaloze/git/mozart2/vm/vm/test/testutils.cc
In file included from /Users/benoitdaloze/git/mozart2/vm/vm/test/testutils.cc:1:
In file included from /Users/benoitdaloze/git/mozart2/vm/vm/test/testutils.hh:5:
In file included from /Users/benoitdaloze/prefix/build/moz2-release-tmp/externals/Source/gtest/include/gtest/gtest.h:58:
/Users/benoitdaloze/prefix/build/moz2-release-tmp/externals/Source/gtest/include/gtest/internal/gtest-internal.h:384:51: error: use of undeclared identifier 'FLT_MAX'
inline float FloatingPoint<float>::Max() { return FLT_MAX; }
                                                  ^
/Users/benoitdaloze/prefix/build/moz2-release-tmp/externals/Source/gtest/include/gtest/internal/gtest-internal.h:386:53: error: use of undeclared identifier 'DBL_MAX'
inline double FloatingPoint<double>::Max() { return DBL_MAX; }
                                                    ^
2 errors generated.

This happens on a build of Mozart2 (https://github.com/mozart/mozart2) on OS X 10.8.5.
For now our fix is to stay at r662 (in vm/vm/CMakeLists.txt) but obviously this is not optimal.

This is most likely due to usage of FLT_MAX and DBL_MAX in gtest-internal.h but not #include-ing <climits> (only <limits>).
Could you therefore add that missing header in gtest-internal.h?

Billy Donahue

unread,
Mar 2, 2014, 1:03:28 AM3/2/14
to Benoit Daloze, Google C++ Testing Framework
FLT_MAX and DBL_MAX are required by C to be defined in <float.h>, which IS included in gtest-internal.h.



Can you give a minimal test program that shows the problem? I think your code may be doing something unusual.



--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Benoit Daloze

unread,
Mar 2, 2014, 6:34:38 AM3/2/14
to googletes...@googlegroups.com, Benoit Daloze
On Sunday, March 2, 2014 7:03:28 AM UTC+1, Billy Donahue wrote:
FLT_MAX and DBL_MAX are required by C to be defined in <float.h>, which IS included in gtest-internal.h.


You are right, I must have somewhat confused it with std::numeric_limits from <limits>.
 
Can you give a minimal test program that shows the problem? I think your code may be doing something unusual.


This was due to a bad "#define __FLOAT_H" in our float.hh which turns out to be the same #define as the one of Clang's float.h.

So, definitely our fault, sorry I only guessed that #define problem today.

Billy Donahue

unread,
Mar 2, 2014, 10:53:47 AM3/2/14
to Benoit Daloze, Google C++ Testing Framework
Hint: Don't use __ for anything ever. It's reserved.


--
Reply all
Reply to author
Forward
0 new messages