I would like to develop my contracts in a way where I can pass a compile time flag to enable/disable debugging code so that the debugging functionality would not be compiled into the "production" version of the contract. eg.

  void cleartables() {
    // clear all table code here

2 Answers 2


Define your variables in the environment variable EOSIOCPP_CFLAGS. If you are curious, just open the eosiocpp file (it's a bash script, a wrapper over clang) to see how the variable is used.

  • Thanks. It's taken me a while to get around to it but that helped a lot. Ive been able to pass macros into eosio-cpp with the newer tools and get exactly what I need done. Commented Sep 16, 2018 at 11:11

you can also pass the values when you compile the contract e.g. eosio-cpp -D=DEBUG ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.