I'm trying to test out some of the # methods of cpp (define, if, include etc). However, my compiler is running into issues when I try to write these in code. For some reason, the code
#include <iostream>
#define DEBUG 1
#if DEBUG
#define X(x) std::cout << x << std::endl;
#else
#define X(x)
#endif
int main(){
X("hi")
X("37")
std::cout << "Hello" << std::endl;
return 0;
}
issues a compile time error that says "expected ';' at the end of declaration" pointing to the line in #endif. I've searched for solutions online, but I'm not sure where a semicolon is needed, if at all. I also get similar errors when I try to define a vector:
#include <vector>
int main(){
vector<string> msg = {"hi", "bye"};
return 0;
}
Is this a compiler issue, or am I missing semicolons somewhere? As for the vector code, I believe the compiler states that the semicolon is missing after variable "msg" (not at the end of the line). Thanks for any help!