|
No I'd like to paste some "TRACE" like function in the release code which is run faster than in debug mode using TRACE().
When the code is executed we can output TRACE() messages to VC window but in release mode I'd like to substitute TRACE() function with something similar but puting its output to file
some hard C console app code:
....
....
TRACE(" %d %d", var1,var2);
...
...
change the same of TRACE() function to put (" %d %d", var1,var2) formated string to file by invoking just that function
9ine
|
|
|
|
|
Take a look at vfprintf .
Nibu thomas
Software Developer
|
|
|
|
|
Make couples of defines, and define TRACE to a function of yours in release mode.
In that function, do the formatting and file writing.
Then you can use the same TRACE-statements in debug as well as in relese mode, and the release-version vill write to a file of your choice.
I won't give you a code sample, since I'm likely to get flamed for it. But it can be done, quite easily.
Put your email address in your profile and I can email you a working example.
|
|
|
|
|
9ine@mail.ru
that would be great
9ine
|
|
|
|
|
You've got it.
I hope you will find it useful.
Kakan
|
|
|
|
|
Still have not recieved it.
I'm going to use just one file for log trace.
9ine
|
|
|
|
|
great thing, thanks, strange that you get 550 smtp error?
9ine
|
|
|
|
|
Actually this part of your idea is good - I am not so sure about the implementation though.
I would take a look at TRACE's implementation. It takes a while to wade through but you can learn a bit along the way. It eventually boils down to calling _snprintf (or _sntprintf for TCHAR usage) into a text buffer (1024 bytes long) and then calling OutputDebugString in AtlDebugAPI.cpp around line 306. OutputDebugString works in release and debug mode as long as a debugger is running.
What I am getting at is in release builds TRACE is compiled to no-ops so you can implement your own trace statements that do essentially the same thing. If you do it right you can disable them all by commenting out a few lines and recompiling.
Good luck.
|
|
|
|
|
There is always room for improvements.
The way I see it there is a distinction between "good" and "good enough"
In this case, the the objective was to get a way of tracing the app in a release build.
Of course, a guy can spend, say 10 hours, to get the trace code perfect in every aspect.
Or, spending 1 hour to get a code that's good enough, and the remaining 9 hours to do the actual debug.
IMO, the second alternative is the best, since it faster will lead to making the "debugee" work.
Correct me if I'm wrong, but that was the goal, wasn't it?
|
|
|
|
|
9ine wrote: I need to test system in release mode using similar to TRACE(" %d %d\n", a,b) geting variable number of arguments to formated string but saveing it to some file. Is there some code available
as others said, write to a file using sprintf or other stream writing. I use sprintf with a stream to sockets so that the debugger can be off system for embedded debugging as well as local.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi,
I have a new requirement to display the meesages in the DOS window instead of writing to a log file where the exe exists.Currently we can invoke an exe from commmand prompt which accepts a command line parameter.
Can someone please tell me how to display the message sin command prompt instead of writing to a log file .
Thanks,
|
|
|
|
|
It depends. cout << "Hello"; is one way but it depends. What type of .EXE is it (console or not)? What libraries are used?
Steve
|
|
|
|
|
HI,
I am using console exe.That exe is used for batch processing.
For example,
I run the command like
c:\>.....\abc.exe ordupd
here ordupd is the commandline paramter tat exe accepts
but i coudn't see any messages here eventhought i used getch() and cout statements
The process terminates to
c:\>... after completing the process.\
Thanks,
|
|
|
|
|
Make sure you #include <iostream> . Then you can write out text like this:
std::cout << "Hello";
If the std prefix annoys you there are a number of way to get rid out it. The quick and dirty method if to add a using namespace std to the .CPP file. NOTE: Adding a using directive to a header file will also work but its bad form.
Steve
|
|
|
|
|
Hi,
It's not working . I think its an MFC exe (inside initinstance () if i put cout<< statement , nothing is reflected in dos winndow.Please if you have any suggestions tell me.
Thanks,
|
|
|
|
|
You just want to know how to display the message in the console right (not how to get the command line arguments) ?
Just use cout for that:
int SomeVar = 5;
cout<<"Some Text"<<SomeVar;
|
|
|
|
|
I would write an interface layer (or class) that accepts your message and has a member variable that specifies the destination for the message.
In the old RTL functions, this would mean using fprintf to output the message but you specify the destination with a file structure pointer. Use stdout for the console or open up a file and pass that pointer to send it to a file.
This could be a global object that gets the destination via a call during your app's initialization. The idea is that you specify only one time where your messages go - not in every single instance.
I don't know what corresponding streams methods would be because I never use them.
|
|
|
|
|
hi
I want to look at the source code of CWnd,CButton,CListBox,CException,...... where to find these sources ?
thank you all
i have VS.net 2003
-- modified at 6:52 Tuesday 2nd May, 2006
|
|
|
|
|
CWnd, CButton and CListBox are defined in AfxWin.h .
CException in Afx.h .
|
|
|
|
|
thank you, but it is a header file.
I am looking for the implementation file.
where will be the definitions of functions of above written classes, not declarations.
can you help ?
|
|
|
|
|
an easy way :
create a simple dialog with one button, then put a breakpoint in your onclick handler, debug step by step, and see where it goes...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
I found that names using the popup menu' that appears when RClick on the name of an object -> then you can find where is is declared or defined as you want.
Only a Note:
the class that you list are only an interface between the programmer and the 'build in' code: you can't reach the implementation of the core of a button or a wnd.
|
|
|
|
|
In VC6 it is in MFC\SRC\WINCORE.CPP...
I am not sure about VS.net. But you can try it.
- NS -
|
|
|
|
|
Hi ,
You can find the files in the VC7/atlmfc folder in the application path for .NET2003.
For more information you can just check on the msdn site at the bottom link
http://msdn2.microsoft.com/en-US/library/bs046sh0.aspx
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
Hi all,
In my MDI application, I need to repaint a child window, which has title "Child Window 3", from the application class. How to use FindWindowEx function to get the window handle of the child window? Or is there an alternative?
Kindly suggest me some ideas.
Thanks in advance,
Sarvan AL
|
|
|
|