1

I'am trying to compile and run a C++ program where is included boost/lexical_cast.hpp in fedora 20, where is installed boost-devel 1.50

What I get is as follow:

ina@localhost Examples]$ g++ -I ../Libraries/ quark_prop.cpp
In file included from ../Libraries/mdp.h:177:0,
                 from ../Libraries/fermiqcd.h:15,
                 from quark_prop.cpp:1:
../Libraries/mdp_utils.h:73:51: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 int is_file(string filename, char permission[]="r") {
                                                   ^
In file included from ../Libraries/fermiqcd.h:15:0,
                 from quark_prop.cpp:1:
/usr/include/boost/assert.hpp: In function ‘void boost::assertion::detail::assertion_failed_msg(const char*, const char*, const char*, const char*, long int)’:
../Libraries/mdp.h:49:14: error: expected unqualified-id before string constant
 #define endl "\n"
              ^
../Libraries/mdp.h:49:14: error: expected ‘;’ before string constant

While in another pc with OS ubuntu 10.04 and boost 1.40 this codes works perfectly.

Any idea of what is happening?

Thank you

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
Ina
  • 11
  • 1

1 Answers1

0

Your message is unrelated to boost.

You cannot pass a string literal as char*. It's always const, so pass it as char const*: Live On Coliru

Regarding the other error in mdp.h, you need to show the relevant code


UPDATE Ah.

The problem is with the define. It's breaking the compilation of the boost header because mdp.h writes;

std::endl

somewhere, and the preprocessor is making that into

std::"\n"

which isn't valid C++.

Remove the define. Use using instead (but not in header files):

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • the idea is that the same code works perfectly in another system with libboost-all-dev 1.40. I am sure that the problem it's not in the mdp.h. I have tested already the code – Ina Feb 06 '15 at 12:40
  • The thing is, newer compilers added the warning I explained (so there are more differences). Also, do you agree it is not compiling? If you want us to help fixing it, you have to show the relevant code. It doesn't matter that it compiles on another system. (Unless you're happy to use the other system instead) – sehe Feb 06 '15 at 12:47
  • AH. @Deduplicator's comment explained things, updated my answer – sehe Feb 06 '15 at 12:48