SPyofgame's blog

By SPyofgame, history, 4 years ago, In English

Does anyone know any simple website or tool or vscode-extension that replace all macros directly into the source code ? I tried to search on google/vscode-extension something like antimacro ..., remove macro ..., replace macro ... but find no result. Thanks for helping ^^

  • Vote: I like it
  • +19
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it +23 Vote: I do not like it

Expanding macros is work of the preprocessor, which is already there in the compiler. G++ has a flag -E (expand macros). Use it like this:

g++ -E file.cpp
  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It was helpful, just wondering if I can expand inline function too ^^

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Inline functions cannot really be expanded as code; think about how you would inline conflicting variable declarations, or return statements. In the compiler they're typically inlined after being translated to the IR.

      • »
        »
        »
        »
        4 years ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        Thank ecnerwala can I ask one more question ? Is there such vscode-extension or website that expands the macros directly instead of calling terminal to run g++ -E file.cpp each time ?

        • »
          »
          »
          »
          »
          4 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Well, I'm sure you can find (or make!) a VSCode extension to run arbitrary terminal commands. I don't know of one, though.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Thanks for sharing. This can actually help during hacking phase.