supposing I have a contract declaration in file t.cpp as follows:

class [[eosio::contract("__CONTRACT__")]] token : public contract {

I would expect to be able to compile it like this:

$ eosio-cpp -D__CONTRACT__=t t.cpp -o t.wasm --abigen

but when I try, I get an empty ABI file.

if I look at what the preprocessor is producing:

$ eosio-cpp -D__CONTRACT__=t -E -dD t.cpp  -o - |grep __CONTRACT__

it looks right:

> #define __CONTRACT__ t
> class [[eosio::contract("__CONTRACT__")]] token : public contract {

and I get further confirmation because if I specify the name during compilation everything works just fine:

$ eosio-cpp t.cpp -o t.wasm --abigen --contract=__CONTRACT__

so are preprocessor symbols just not supported by eosio-cpp as they are in standard C/C++ compilers?


1 Answer 1


I'd start by removing the quotes from "__CONTRACT__". Anything in quotes is a string literal, and should not get replaced.

If you need the quotes right there, try specifying the quoted string on the right side of the definition, like #define __CONTRACT__ "t".

  • ah... quite right. I guess the preprocessor respects literals. a million thanks!
    – ekkis
    Commented Jun 18, 2019 at 0:48
  • as a side note, the quotes have to be escaped in the call: -D'__CONTRACT__=\"t\"'
    – ekkis
    Commented Jun 18, 2019 at 1:02
  • you seem good with this stuff: github.com/EOSIO/eosio.cdt/issues/529
    – ekkis
    Commented Jun 18, 2019 at 2:18

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.