I am using boost 1.63 and when I compile my application that includes #include <boost/algorithm/string.hpp>
.
GCC complains:
In file included from /opt/boost/boost/mpl/aux_/na_assert.hpp:23,
from /opt/boost/boost/mpl/arg.hpp:25,
from /opt/boost/boost/mpl/placeholders.hpp:24,
from /opt/boost/boost/iterator/iterator_categories.hpp:17,
from /opt/boost/boost/iterator/iterator_facade.hpp:14,
from /opt/boost/boost/range/iterator_range_core.hpp:27,
from /opt/boost/boost/range/iterator_range.hpp:13,
from /opt/boost/boost/range/as_literal.hpp:22,
from /opt/boost/boost/algorithm/string/trim.hpp:19,
from /opt/boost/boost/algorithm/string.hpp:19,
from [my source that includes <boost/algorithm/string.hpp>]
/opt/boost/boost/mpl/assert.hpp:188:21: warning: unnecessary parentheses in declaration of ‘assert_arg’ [-Wparentheses]
failed ************ (Pred::************
^
/opt/boost/boost/mpl/assert.hpp:193:21: warning: unnecessary parentheses in declaration of ‘assert_not_arg’ [-Wparentheses]
failed ************ (boost::mpl::not_<Pred>::************
^
I looked at the source and complained section is:
template< typename Pred >
failed ************ (Pred::************
assert_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type )
);
template< typename Pred >
failed ************ (boost::mpl::not_<Pred>::************
assert_not_arg( void (*)(Pred), typename assert_arg_pred_not<Pred>::type )
);
Questions:
failed ************ (Pred::************
? The syntax looks weird to me.I searched online, and the closest, related one is this. But its solution seems to just suppress the warnings.
Thanks!
If the value of y is always 1, 2 or 3, then x is always initialized, but GCC doesn't know this. To suppress the warning, you need to provide a default case with assert(0) or similar code. This option also warns when a non-volatile automatic variable might be changed by a call to longjmp.
GCC 4.3+ now has -Q --help=warnings , and you can even specify --help=warnings,C to just print out the C related warnings.
You can use the -Werror compiler flag to turn all or some warnings into errors.
The C++ compiler comes with a lot of useful warnings that warn you about potential errors and issues in your code. You always want to compile with warnings. A warning flag starts with -W and then the name of the warning, for example -Wconversion which warns about implicit conversions.
Normally GCC and Clang automatically suppress warnings from headers in /usr
. However, it seems that for /opt
it doesn't. To tell the compiler that the boost headers should be treated as system headers, use -isystem
instead of -I
to add the boost headers to the include paths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With