Trace () usage in VC, and finally learned a bit of fur, so tired

Source: Internet
Author: User

My personal conclusion: Recently I saw network programming come across trace statements, but I don't know where to output them. I did not find any materials for one night. Today I finally found them on csdn, the method is as follows:

1. Add a trace statement to MFC

2. In tools> MFC tracer, select enable tracing and click OK.

3. debug and run go (F5) (Note: not execute '! 'The reason why we couldn't see trace content in the past is that it wasn't debugging, '! ', Remember, remember)

4. The trace content will be displayed in the debug window in the output. The debug execution will automatically jump from the build window to the debug window, where the trace content will be displayed, ^_^

The following is a detailed description of the trace:

====================================

Trace macro is very useful for program debugging in VC and has functions similar to printf. This macro only appears in the debug version of the program, when release is used, the macro will have complete messages, helping you reduce the amount of code when debugging is also performed.

The format is as follows:

Trace ("ddddddddddd ");

Trace ("Wewe % d", 333 );

There are also trace0, trace1, trace2... Corresponding to 0, 1, 2, respectively .. Parameters

Trace information is output to the output window of the vc ide environment (which window Indicates the project error prompt you compile), but it is limited to running your debug version program in the VC.

Trace information can also be captured using debugview. In this case, you cannot run your program in the vc ide environment, but run the build debug version program separately, in this case, you can see the output in debugvie format in the debugview window.

There are four trace usage methods in VC:

1:

Trace, that is, the output string without dynamic parameters, similar to C's printf ("output string ");

2:

The string in the trace can contain a parameter output, similar to C's printf ("... % d", variable );

3:

Trace can contain two parameter outputs, similar to C's printf ("... % d... % F", variable 1, variable 2 );

4:

Trace can contain three parameter outputs, similar to C's printf ("... % d, % d, % d", variable 1, variable 2, variable 3 );

The trace macro is like the printf function we used in the C language before, so that the program outputs some debugging information during the running process, so that we can understand some of the program status. But the difference is:

The trace macro outputs only in the debugging status, and the printf function used previously has outputs in all circumstances. Like the printf function, the trace function can accept multiple parameters, for example:

Int x = 1;
Int y = 16;
Float z = 32.0;
Trace ("this is a trace statement/N ");
Trace ("the value of X is % d/N", X );
Trace ("x = % d and Y = % d/N", x, y );
Trace ("x = % d and Y = % X and Z = % F/N", x, y, z );

Note that the trace macro only works for the debug project. In the release project, the trace macro is ignored.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.