Dynamic variable cpp compilation [duplicate]
问题 This question already has an answer here : g++ command line macro define byte stream (1 answer) Closed last year . I wish I could edit a variable in a .h file since compilation Example: #include <iostream> #include <stdlib.h> #define HOST (char *)"http://localhost/" #define PATH "insert" I want to edite HOST from compilation like this: g++ -o output source.cpp -HOST http://mywebsite/ 回答1: You can easily do that with something like this: #include <iostream> #include <stdlib.h> #ifndef HOST