C++ 动态变量cpp编译

C++ 动态变量cpp编译,c++,compilation,C++,Compilation,我希望我能在编译后在.h文件中编辑一个变量 例如: 您可以通过以下方式轻松做到这一点: g++ -o output source.cpp -HOST http://mywebsite/ #include <iostream> #include <stdlib.h> #ifndef HOST #define HOST (char*)"http://localhost/" #endif #define PATH "insert" #包括 #包括 #ifndef主机

我希望我能在编译后在.h文件中编辑一个变量 例如:


您可以通过以下方式轻松做到这一点:

g++ -o output source.cpp -HOST http://mywebsite/
#include <iostream>
#include <stdlib.h>

#ifndef HOST
  #define HOST (char*)"http://localhost/"
#endif

#define PATH "insert"
#包括
#包括
#ifndef主机
#定义主机(字符*)”http://localhost/"
#恩迪夫
#定义路径“插入”

然后,在命令行上,您可以指定
'-DHOST=(char*)“which”
(将使用它),或者不传入任何
-DHOST=
标志,并且将使用头中的默认值。

g++-o output source.cpp-DHOST='(char*)”http://localhost/“
正是我需要的答案!谢谢你
#include <iostream>
#include <stdlib.h>

#ifndef HOST
  #define HOST (char*)"http://localhost/"
#endif

#define PATH "insert"