|
So if you have a non-static variable in that same function, will the debugger see it?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Yes, of course it will.
Regards,
BB
|
|
|
|
|
Definitely, in order to watch, I have to set a breakpoint. The debugger gives this error message.
CXX0017: Error: symbol "i" not found
What I understand here is that static variables are not created and destroyed when a procedure is called. They have a lifetime of program. Why debugger is showing this message is because, I have set the breakpoint in procedure(), so debugger has a context of procedure(). So, it is unable to provide a watch on "i".
I tried to watch "i" in WinMain() but again WinMain() is also a function. Now, what I left is that declare a global variable, set a breakpoint there and watch "i". Perhaps it work.
The other approach I am using is having a pointer to this static variable "i" in procedure(). In this way, I am able to watch the contents of static variable "i". e.g.
void procedure(void)
{
static int i;
int * pi = &i;
...... code follows ......
}
|
|
|
|
|
hashimsaleem wrote:
Why debugger is showing this message is because, I have set the breakpoint in procedure(), so debugger has a context of procedure(). So, it is unable to provide a watch on "i".
The debugger should show any and all variables that have "current" scope, whether they are global, static, or local. I just tried this and it does work. Something else is at play here.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
what do you mean by "current" scope? Please explain.
|
|
|
|
|
int a;
void procedure( int b )
{
static int c;
int d;
}
void foo( int e )
{
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
This is however VC6-only problem (I have SP4 on it). Under .NET everything is clearly visible.
Regards,
BB
|
|
|
|
|
Hi guys
I'd like to ask the user to save his Doc before exit in my SDI app and then do like he pressed the Save button in menu.
Where I have to do the call, and how?
Best Regards
Doc
|
|
|
|
|
With a "normal" SDI app, everything is already in place. If the document's data is serializable, put your code in the Serialize() method. Otherwise, put your code in the OnSaveDocument() method.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
You need to monitor when the user has made a change in the document which you count as significant enough to require saving. For example the user updated a text box on your form, or drew a circle, or whatever. When that happens you must call the SetModifiedFlag(TRUE) method of your document class. The framework will then automatically prompt the user to save the document if they close the window.
Of course you still need to add code in OnSaveDocument or Serialize to actually do the work of saving to a file just as the previous user indicated.
Hope it helps...
--
The Obliterator
|
|
|
|
|
At some point use SetModifiedFlag(TRUE) and before closing have SaveModified() in the code.
|
|
|
|
|
Is there any Windows API function to determine the dependent DLLs of an application or a DLL?
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
No, you'd have to roll your own. It's a matter of parsing through the import tables of the file. There are utilities in place for this already, however. One of them, Depends, ships with Visual Studio.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
So, isn't there any function or method to parse the import table? I have to load the dependent DLLs dynamically through my application. I have no more options to use the utilities? I appreciate it if you have more info.
Regards
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
Arash Sabet wrote:
So, isn't there any function or method to parse the import table?
No, you'd have to make your own.
Arash Sabet wrote:
I have to load the dependent DLLs dynamically through my application.
Why can't you just let the DLL/EXE load its own?
Arash Sabet wrote:
I have no more options to use the utilities?
Don't know what you mean by this.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
My question is that whether there any API function in VC++ or C# or... to parse the import table? What's the clean way to parse the impprt table?
thanks.
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
Arash Sabet wrote:
My question is that whether there any API function in VC++ or C# or... to parse the import table?
As I've already indicated, there is nothing built-in. You'd have to roll your own.
Arash Sabet wrote:
What's the clean way to parse the impprt table?
Knowing the layout of the PE file format is very helpful.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks David,
Just my final query:
Are the DLLs that are loaded dynamically by AfxLoadLibrary(..) function included in the PE?
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
No, only libraries that are implicitly linked are stored in the import table.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
I'm having a really strange problem with one of my classes.
Upon destruction visual c reports damage.
I installed a trial of purify and it catches the damage during constructor...
its when a member boolean variable gets assigned to false????
How is that possible?
I'm certain its not the fault of the classes because I can replicate it even without calling any member functions. The damage occurs immediately in the constructor of which there are only two lines (both of which assign member variables to defaults).
If I remove the assignments from the constructor purify detects no problems.
The only thing I can think of is its something to do with the class being derived from a class which uses multiple inheritence. Are there any documented bugs relating to this?
I found one related article on MSDN[^] but the solution didn't help
Here is a replica of my structure:
.----------.
|CObject |
| |
·^---------·
|
|
.^---------. .----------.
|Class A | |Class B |
| | | |
·-------^--· ·^---------·
| |
| |
| |
| .^---------.
| |Class C |
| | |
| ^----------·
| |
| |
.^-------^-----.
|Class D |
| |
·^-------------·
|
|
|
.^-------------.
|Class E |
| |
·--------------·
The problem occurs in class E.
--
The Obliterator
|
|
|
|
|
Probably not a bug in the compiler.
Usually problems like this are the result of header files not matching the code that is being pulled in from a library--like the header files have been updated and the library not recompiled, or building with debug on and linking with non-debug libraries.
|
|
|
|
|
I'm using Visual C++ 6.0
I'm trying to creat a small Inventory program to keep track of my CD sales
First I want to create a file called cd1.txt and be able to update it with the following:
Total Onhand
60
Then each time someone clicks on the OnRadio1 substract from the Total OnHand.
Total Ordered
10
Total OnHand
50
Once the Total OnHand gets below 20 dislpay a message box to tell me to I need to update the cd1.txt file. I should then be able to add to total OnHand
for a new total.
This is what I have so far. And It doesn't seem to work. Could someone get me started on the right track?
void CCdInventoryDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
FILE*cd1;
char buffer[81];
int i,ch ;
cd1 = fopen("cd1.txt","a+"); //create cd1 text file
ch = fgetc(cd1);
for(i=0; (i < 80) && ( feof(cd1) == 0); i++)
{
buffer[i] = (char)ch;
ch = fgetc( cd1 );
}
/* Add null to end string */
buffer[i] = '\0';
fprintf(cd1, "%d", buffer );
fclose( cd1 );
}
|
|
|
|
|
Not to sound rude but why do you want to use a text file? I would suggest that you either use an .ini file or store those three entries in the registry. That way, you won't have to worry about reading from a text file, parsing the strings, checking for errors, updating them etc.
mike.beck wrote:
And It doesn't seem to work
What is it that doesn't work? In your fprintf statement, you are trying %d and that works for decimals. You might not be printing what you want to print.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Hi Toni78,
It doesn't sound rude... I just need to create a simple inventory program for my cd's....And I guess I really don't know what to do....
|
|
|
|