简体   繁体   English

fedora 20上的boost / lexical_cast

[英]boost/lexical_cast on fedora 20

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 我正在尝试编译并运行C ++程序,其中在fedora 20中安装了boost-devel 1.50 boost/lexical_cast.hpp ,在其中安装了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. 在另一台装有ubuntu 10.04和boost 1.40操作系统的PC上,此代码可完美运行。

Any idea of what is happening? 有什么想法吗?

Thank you 谢谢

Your message is unrelated to boost. 您的消息与提升无关。

You cannot pass a string literal as char* . 您不能将字符串文字传递为char* It's always const, so pass it as char const* : Live On Coliru 它始终是const,因此将其作为char const*传递: Live On Coliru

Regarding the other error in mdp.h , you need to show the relevant code 关于mdp.h的其他错误,您需要显示相关代码


UPDATE Ah. 更新啊。

The problem is with the define. 问题出在定义上。 It's breaking the compilation of the boost header because mdp.h writes; 因为mdp.h写入,这破坏了boost头的编译;

std::endl

somewhere, and the preprocessor is making that into 某个地方,预处理器将其变成

std::"\n"

which isn't valid C++. 这不是有效的C ++。

Remove the define. 删除定义。 Use using instead (but not in header files): 改用using (但不要在头文件中):

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM