c ++:带有宏定义字符串的concat常量字符串

时间:2016-12-02 15:11:41

标签: c++ string macros

我想连接常量字符串和宏定义的字符串。

#define DEEP_DRIVE_NET "C:/Users/tumh/hookv/deep_drive_model.prototxt"
#define DEEP_DRIVE_WEIGHT "C:/Users/tumh/hookv/caffe_deep_drive_train_iter_35352.caffemodel"
CHECK(file_exist(DEEP_DRIVE_WEIGHT)) << "Net Weight " + DEEP_DRIVE_WEIGHT + " Not Found";
CHECK(file_exist(DEEP_DRIVE_NET)) << "Net definition " + DEEP_DRIVE_NET + " Not Found";

来自msvc 2013编译器的编译错误

C:\Users\tumh\hookv\samples\Test\Inference.cpp(28): error C2110: '+' : cannot add two pointers [C:\Users\tumh\hookv\build\NativeTrainer.vcxproj]
C:\Users\tumh\hookv\samples\Test\Inference.cpp(29): error C2110: '+' : cannot add two pointers [C:\Users\tumh\hookv\build\NativeTrainer.vcxproj]

如何连接这些字符串?

感谢。

1 个答案:

答案 0 :(得分:3)

省略CHECK(file_exist(DEEP_DRIVE_WEIGHT)) << "Net Weight " DEEP_DRIVE_WEIGHT " Not Found"; CHECK(file_exist(DEEP_DRIVE_NET)) << "Net definition " DEEP_DRIVE_NET " Not Found"; 操作以连接c风格的字符串文字:

{{1}}