0

I was trying to set up two different type of code for my project.When I try to run the following code nothing is printed.I am using cmake and mingw.

#include <iostream>

int main(int, char**) {
#if DEBUG
std::cout<<"Hello from debug"<<std::endl;
#endif
#if RELEASE
std::cout<< "Hello from release"<<std::endl;
#endif
}
Bruk
  • 152
  • 2
  • 7

1 Answers1

1

I recommend using NDEBUG, since it's standardized. It's defined for non-debug -- while normally used with assert, I've used it for other things too.

#include <iostream>

int main() {
#ifndef NDEBUG
    std::cout << "Hello from debug" << std::endl;
#else
    std::cout << "Hello from release" << std::endl;
#endif
}
ChrisMM
  • 8,448
  • 13
  • 29
  • 48