Exhibit the power of Trace

zhaozj2021-02-11  214

Recently, I have been doing a small project. Since the middle algorithm is more cumbersome, it is very messy. It has an error. It is all chaotic. It is especially hoped to output a monitor value in the need to monitor the intermediate algorithm, first think Over-breakpoint debugging, but every time they constantly interrupt the program, it is very inconvenient. I tried Trace, but it must be done in debug debug mode, it feels very painful. I watched the in-depth MFC of SIR, and provided a detailed explanation of MFC reconstruction DBWIN in the appendix, suddenly ecstatic, carefully studied, but I still like DBWIN this tool, god, god, god It is really saved that the process of the water is given to us, just in MSDN, you can get it easily, huh, huh, this is the famous Paul Dilascia, don't doubt it, but every time you want to use this When the tool is time to modify the source code, it is really trouble, but also pay attention to the location of the initializer, I feel a bit uncomfortable, I have seen a header file that requires the included header, and the initialization program you want to call, I can count the energy You cannot add yourself if you generate a Debug program, initialization must first call, pair, construct a global object, and write a class, put the initialization program in the constructor of the global object, the source program is as follows:

//Mytrace.h

#ifndef __mytrace_h__

#define __mytrace_h__

#ifdef _Debug

#include

Class myTrace

{

PUBLIC:

Mytrace ()

{

:: mfxtraceinit ();

}

~ Mytrace () {}

}

Mytrace_mytrace;

#ENDIF / / _ Debug

#ENDIF / / __MYRTACE_H___

Put this file and , in the default containment, if you want to use DBWIN, just put myTrace.h this file in your program, it is best to include building theApp In that file, you can monitor all the procedures you want to monitor in your program, wow, it is indeed a lot. Open the dbwin window, the Trace string you join, clearly appear in the monitor window, you don't even have to open the VC environment, run your generated debug program, so if you want to debug several programs at the same time, if you are related to the program It is very convenient to communicate, it is very good.

But each time you have to include a header file, still a bit trouble, can you embed this file into the AFXWIN's header file, because you want to write the MFC program, this header file must be included, hurry to try, wrong, error It seems that there is a repeated definition, but this header file has been used to ensure that there is no repeated definition, view the relevant information about this connection error, oh, it seems to be caused by some of the relationships of VC, but work hard. Long time still can't solve it, posting this article I would like to ask you prawn. Maybe you have a better way to Trace, hope to enlighten, have a better solution for the mistakes I have, I hope that I am grateful. Unsatisfactory. Leave my mail here, Dyroo @ 163.com

转载请注明原文地址:https://www.9cbs.com/read-5285.html

New Post(0)