GCC compiler command to display #ifdef

Asked

Viewed 147 times

8

What compiler command do I use to display this line at runtime?

#ifdef DEBUG
    double tInicio_=clock() ;
#endif
  • 1

    I don’t understand what you want, your code is not running this and you want it to run? You are compiling as debug? Give more context to the question.

  • That, I need to know how to compile it and run in order to show this line, I know you have a proper command for this, I only know to compile: gcc <file>. c -o <file>. exe -lm and execute: . /<file>. exe

  • @Thiagoprestes if the given answer solved, you can click on the blue V next to it to mark as accepted and as solved.

  • @Thiagoprestes Did the posted answer solve your problem? Do you think you can accept it? If you don’t know how you do it, see [tour]. This would help a lot to indicate that the solution presented was useful to you and to give an indication that it is satisfactory. You can also vote on any and all questions or answers you find useful on the entire site. Accepting and voting are separate things.

1 answer

6

Just use the directive -D at the GCC command line:

-D DEBUG

This will create a definition of DEBUG what will make this #ifdef be compiled and therefore run when the application is called (of course, it depends on where this is used). This is linking this "variable", so it existing does the ifdef be true.

Other things need to be right in the code to work, but that’s not how you know by the question.

  • Oops, that’s what I wanted to know, thank you very much, I’m using it at the end of the code, it’s not within another conditional, so it will run anyway. VLW even in!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.