|
How 'bout just passing the caller as a string argument?
Getting the calling function's name as a string is way beyond my knowledge
|
|
|
|
|
It's a good idea,but didn't fit my application.
Scratch
|
|
|
|
|
You want a stack trace, huh?
I did it once and regreted it. It was a great bunch of work.
Some starting points:
1. Look at the StackWalk Win32 API function. Walk the stack until you find the calling function.
2. Once with the address of the calling function, you'll need the SymFromAddr Win32 API function.
3. You'll need to ship the PDB file together with your application, because the Symbol functions will need this file.
If you only need this info for debugging purposes, you could try looking, IIRC, the address (&i)[1] (the address of the first parameter + 4 bytes. In your case, the parameter is an int), which will give you the return address on the stack. This is a hack and can fail for a hundred reasons, including the automatic inline made by the optimizer. The right way of doing it is the StackWalk way.
I see dumb people
|
|
|
|
|
How about creating a global array of some appropriate size, adding a call in every function in your code to add its own name to the array, and then at any point, just get the last so-many elements to know where you came from?
It's not really a call "stack" as much as a call "trace." The caller of any function would be the last element in the array.
The function to add to the array would have to do all the proper subscript incrementing and roll-around, making it a circular list of the last some-number of functions called.
This may not be appropriate, because you do have to add something to every function.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
i am new user of vc++.How do i start it.Actually i am thinking of making own operating system.please give me suggestion.
|
|
|
|
|
I hope this is a joke
What about reading books?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Rajes wrote:
Actually i am thinking of making own operating system
ROTFLMAO!
That was a good one!
Buy a goog book, do you have ANY C++ knowledge?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
nice joke
|
|
|
|
|
Rajes wrote:
Actually i am thinking of making own operating system.
It's good to meet a man who is not scared of a challenge. But I'm afraid that's not gonna happen. Buy some books on C++ ( NOT Visual C++, just the C++ language ) and do the exercises in them, and ask lots of questions here. If you find it hard going, consider learning C# first.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
|
I have to write a program to calculate a user's year of birth, given their age. I want to use the year from the system clock, but I have no idea how to do this. Could someone show me some code that would accomplish this??
As simple as: cout<<"systemtime"-age; is what I need.
I'm not real good with C++ yet, so please try and make it simple.
|
|
|
|
|
sorry....not cout<<"systemtime"-age; I meant systemyear. All I need is the current year.
|
|
|
|
|
|
int getCurrentYear()
{
time_t t;
time(&t);
tm* pTM = localtime(&t);
return pTM->tm_year + 1900;
}
This should do it, although I haven't compiled or much less tested it.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
How do I obtain the return value inside my code? Like if I wanted to take that value and subtract a number from it.
|
|
|
|
|
I don't have MSDN now but I can remember GetTime() or GetCurrentTime() do this.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
can anyone give the equivalent of converting the integer to a string using the shlwapi.h
????????????????
|
|
|
|
|
I'm curious to why you want to use ShellFunctions for converting an integer to a string. Why can't you use itoa or one for the ?printf functions, or even CString::Format?
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
just wanted to know ?
can you help out ?
|
|
|
|
|
A look through MSDN doesn't show any such function apart from wvnsprintf. You'd be better of sticking the the C Runtime versions though, as there are security warnings plastered all over this function.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
well i too did'nt get any function from MSDN and also after looking at the .h file. it might be containing the function but since all the functions are not documented i am not able to figure out the actual one.
anyway thanks
|
|
|
|
|
i am doing a project in which i am using CRgn variables to create a rgn, after creating a region i using the function
pDC->FrameRgn(&rgn,*brush,1,1);
this function frames the boder of the region in rgn
the problem is i see a framed region of 1 pixels thickness on the monitor but when it comes to printing the width of the lines is taken as 10 pixels and i get a different output when i take a print out
i am not able to under stand what is the problem ?
can any one can solve the problem and help me.
sri
|
|
|
|
|
hi
i like to implement tables in my vc++ application like
msword->Insert->Table option. Please help me how can i implement this.
thank you in advance
from
venugopal
|
|
|
|
|
Hi,
I am trying to modify some ISAPI code. for getting the domain name I use the GetServerVariable() call and pass "HTTP_HOST" and then parse the string(the host name). The problem is that for our internal environment, people type things like
"http://internal1"
This will take them to the correct URL.
Unfortunately the GetServerVariable with "HTTP_HOST" is returning "internal1" as the name. Its not giving the fully qualified domain name. Is there any way I can get the fully qualified name (eg: http://internal1.somedomain.com)?
Or do I need to use some WinSock functions? if yes which one?
Thanks in advance..
Madhu
|
|
|
|
|
I'm trying to build 2 apps in VC++6: one that writes character strings to a serial port (COM2) and one that reads them on another port (COM1). I'm running both apps at the same time, have the two serial ports connected with a NULL modem serial cable. Each app works fine by itself when I link the PC to a separate device through the serial cable.When I link COM1 and COM2, the writer app writes characters to COM2, but the reader app fails to read them on COM1. I'm not using any flow control. What am I doing wrong?
Any help is greatly appreciated.
|
|
|
|