0

I'm experiencing very wierd error when trying to build my program with Boost thread.hpp included (ver. 1.54, but tried also lower):

/home/seweryn/boost/include/boost/functional/hash/detail/float_functions.hpp:78: error: expected nested-name-specifier before 'float'
/home/seweryn/boost/include/boost/functional/hash/detail/float_functions.hpp:78: error: two or more data types in declaration of 'parameter'
/home/seweryn/boost/include/boost/functional/hash/detail/float_functions.hpp:86: error: expected nested-name-specifier before 'float'
/home/seweryn/boost/include/boost/functional/hash/detail/float_functions.hpp:86: error: two or more data types in declaration of 'parameter'
/home/seweryn/boost/include/boost/functional/hash/detail/float_functions.hpp:94: error: expected nested-name-specifier before 'float'
/home/seweryn/boost/include/boost/functional/hash/detail/float_functions.hpp:94: error: two or more data types in declaration of 'parameter'

The float_functions.hpp (fragment):

76. namespace boost {
77.    namespace hash_detail {
78.        template <typename Float>
79.        struct call_ldexp {
80.            typedef Float float_type;
81.            inline Float operator()(Float x, int y) const {
82.                return std::ldexp(x, y);
83.            }
84.        };
85.
86.        template <typename Float>
87.        struct call_frexp {
88.            typedef Float float_type;
89.            inline Float operator()(Float x, int* y) const {
90.                return std::frexp(x, y);
91.            }
92.        };
93.
94.        template <typename Float>
95.        struct select_hash_type
96.        {
97.            typedef Float type;
98.        };
99.    }
100.}

The build command is:

g++ -I/usr/include -I/home/seweryn/boost/include -I/home/seweryn/include -I/home/seweryn/libmpeg7.2/src -O0 -g3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP -MF"src/TestApp.d" -MT"src/TestApp.d" -o "src/TestApp.o" "../src/TestApp.cpp"

It looks like the Float type is recognized as standard float and it causes the error.

I'm quite unexperienced to C++ so any help is appreciated.

Thanks

UPDATE: It may be important, that this app worked on previous environment (Ubuntu). After moving it to the new one (CentOS) and installing Boost, it fails.

TomaszP
  • 3
  • 2
  • 3
    Can we see the code in `TestApp.cpp`? It looks like a macro might be the cause. – Jesse Good Oct 10 '13 at 08:19
  • Also your g++ build command should include "-lboost_thread" and also "-lpthread" may be required. – Lectral Oct 10 '13 at 08:23
  • @Jesse In TestApp.cpp (actually in one of the header files) I am adding `#include ` only. Without it it builds with no errors. @Lectral Do you mean including laso boost_thread and pthread folders? They are inside boost/include so they should be included. – TomaszP Oct 10 '13 at 08:41
  • @TomaszP: Your code is causing an error in the `boost` header. Do you use any `#define`s? – Jesse Good Oct 10 '13 at 08:49
  • @Jesse: Yes, I'm using `#ifndef MPEG7DESCRIPTORS_H_ #define MPEG7DESCRIPTORS_H_` at the beginning of the header file. Without it, there's still the same error. – TomaszP Oct 10 '13 at 09:17
  • @TomaszP: Which version of g++ do you use on CentOS, which one did you use in Ubuntu? – Zeta Oct 10 '13 at 09:30
  • 3
    Try adding `#undef Float` right before `#include `. Does it help? – n. m. could be an AI Oct 10 '13 at 09:41
  • @n.m.:Yes, it helped! I've added `#undef Float #undef Char` and it's working now. Thanks! – TomaszP Oct 10 '13 at 10:09
  • 4
    @TomaszP, that means some idiot has defined `Float` as a macro. You should shoot them and dump their body at sea, then teach their descendants about `typedef`. – Jonathan Wakely Oct 10 '13 at 10:59
  • You may want to find out where these #defines come from so you could try avoiding these conflicts in the future. – n. m. could be an AI Oct 10 '13 at 12:50
  • You can also play with the order of #include lines and try moving the problematic ones to the end. – n. m. could be an AI Oct 10 '13 at 12:52
  • Yes, you're right guys. In one of the header files which I include in project, there is a macro `#define Float float`. Thanks again for the help! Can I mark the comment as the asnwer? – TomaszP Oct 11 '13 at 11:18

0 Answers0