Get the App
SLTechnology News&Howtos  ›  Development  › 

How C++ uses debug tags

Shulou Source: shulou.com Published: 2022-06-01 04:01:19 09月16日 Update

This article is about how C++ uses debug tags. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Use debug tags

It is a common debugging strategy to use the corresponding auxiliary code when debugging the program (such as outputting intermediate results, etc.) and to hide the code after debugging.

This strategy can be implemented with the help of # define, # ifdef, # endif and compilation instructions. Specifically, when debugging a program, use the compiler's command-line arguments to define debugging tags (equivalent to macros defined in # define in the program), and then include the corresponding debugging code between # ifdef and # endif. When the final debugging of the program is completed, when the release is generated, the debug code in the program disappears as long as the debug token is no longer provided in the compiler command line arguments. The common debug flag is _ DEBUG (in VC++ 2012), the compiler debug version of the program defaults to the macro _ DEBUG. Examine the following procedure.

# include using namespace std;int main () {int iTunes 5 nbsp ifdef _ DEBUG cout

Tags: Programs tags code compilation time compiler cymbals between content parameters commands common more strategy article good practical three in use specifically Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology Linux MySQL MariaDB