I am trying to do the following:
CComboBox *pComboBox;
CString newString;
int iNewSelection = -1;
pComboBox = (CComboBox*)(this->GetDlgItem(IDC_METHOD));
NewMethod = pComboBox->GetCurSel();
if(NewMethod != CB_ERR)
{
pComboBox->GetLBText(NewMethod, newString);
}
In the above NewMethod is an integer.
It works fine (kind of). The issue is following:
When I debug through the above code, stop at the IF condition and put the mouse cursor on NewMethod, I get some random value, but then it does go through the IF condition and I can see correct value in newString.
My question is: why I do not see correct integer value in NewMethod?
Many thanks.
Best Regards
Chintan
It looks like you're source code and binary are out of sync, ie. you're debugging a DLL/EXE that has been compiled with different version of the source code.
During debug activate the Debug->Windows->Modules window and check that the DLL/EXE you're debugging is the same as the one you've been compiling with your source code (check date/times, symbol files etc.).
Related
I am fairly new to using gdb debugger and so coming across the code being displayed when I ran gdb left me having no use for the debugger. I am unfamiliar with the code being displayed but a did a little research and I assume I accidentally opened up a "thread"? It's hard to explain something I do not understand but I will link a picture explaining what I am talking about. Basically I want to revert back to the "basic" display of my actual code and not this: displayed by the debugger
Your program called one of scanf family of functions, with a NULL stream.
Usually this happens when you don't check for errors. For example:
FILE *fp = fopen("/file/which/does/not/exist", "r");
char ch;
fscanf(fp, "%c", &ch); /* BUG: should check fp!=NULL first. */
You should always check return value from any function that may fail.
You can see which code called into the fscanf with GDB where command.
Hi I have a big problem: We created a program in C++/Qt 4.8.4 /Qt Creator 2.8.1 years ago that while executing runs another executable (written and compiled in FORTRAN). Everything worked well.
We recompiled our Fortran-Code with the new version of Visual studio and now suddenly it doesn`t work any more. I looked into my C++-Code and found the position where the program crashes:
std::string Executable = ApplicationName.toStdString();
bool RunOK= system((Executable+" > "+"X.out2").c_str());
QString ExeName = (Executable+" > "+"X.out2").c_str();
QString tf = QString::number(qweee);
if(system((Executable+" > "+"X.out2").c_str()))
{
msg.showMessage("msg.showMessage("An XXX error occured during calculation......((Executable+ > +X.out2).c_str(): "+ExeName +"......(system((Executable+ > +X.out2).c_str()): "+ QString::number(RunOK));
if(QFile(OutputFiles[0]).exists())
QFile(OutputFiles[0]).remove();
}
Somehow system((Executable+" > "+"X.out2").c_str()) gets to be true which didn`t happen before.
This seems to happen either in the c_str-command or in the system()-command.
We had some missing dll-issues before. Is this another dll-problem and if so which?
Can anybody help us on this?
Thank you
The return value of system is an integer, not a boolean. Its value is only defined for one very special case, system(nullptr). That's not the case here. So whether you get a zero or non-zero result depends on your particular C++ implementation, which has indeed changed. ("New visual studio version"). You can't rely on non-zero means error
c_str() is not a suspect at all.
I have a C++ program which works well when I compile with no additional options. However, whenever I use cmake -DCMAKE_BUILD_TYPE=Release there is a very specific part of the code which stops working.
Concretely, I have an interface for a Boost Fibonacci Heap. I am calling this function:
narrow_band_.push(myObject);
And this function does the following:
inline void myHeap::push (myStruct & c) {
handles_[c.getIndex()] = heap_.push(c);
}
where heap_ is:
boost::heap::fibonacci_heap<myStruct, boost::heap::compare<compare_func>> heap_;
For some reason the heap_size is not being modified, therefore the rest of the code does not work because the next step is to extract the minimum from the heap and it is always empty.
In Debug mode it works ok. Thank you for your help.
EDIT - Additional info
I have also found this problem: I have a set of code which do simple math operations. In Release mode the results are incorrect. If I just do cout of a couple of variables to check their values, the result changes, which is still incorrect but quite strange.
I solved the problem. It was funny but in this case it was not initialization/timing issues common in the Release mode. It was that the return statement was missing in a couple of functions. In debug mode the output was perfect but in the release mode that failed. I had warnings deactivated, that is why I did not see it before.
wont load my picture
my default error message which is"error loading picture.bmp" pops up every time and wont run
#include "allegro.h"
int main(void)
{
char*filename="picture.bmp";
BITMAP*image;
int ret;
allegro_init();
install_keyboard();
set_color_depth(32);
ret=set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
if(ret!=0)
{
allegro_message(allegro_error);
return 1;
}
image=load_bitmap(filename,NULL);
if(!image)
{
allegro_message("error loading %s",filename);
return 1;
}
blit(image,screen,0,0,0,0,SCREEN_W,SCREEN_H);
destroy_bitmap(image);
textprintf_ex(screen,font,0,0,1,-1,"%dx%d",SCREEN_W,SCREEN_H);
while(!keypressed());
allegro_exit();
return 0;
}
END_OF_MAIN()
You're going to need to provide some more information...
What platform are you using? (MS Visual C++? Linux? Mac?...)
Which version of Allegro? (I'm guessing 4.x)
Assuming your question is, "How do I get my Allegro program to display my bitmap as intended," try to
Make sure the resulting executable file and picture.bmp are in the same directory. My guess is you are using some type of Microsoft IDE on Windows and you are trying to run the program from within the IDE (like via the debug menu or pressing F5) The resulting executable is put in a special output directory. It can't find your picture.bmp file.
Alternatively, you can try providing the full path to your picture.bmp file. You should only use this method to see if this is indeed the problem, though.
I believe your program might not be able to locate the bitmap image you are attempting to load. Try inserting the exact path to your bitmap in your code.
For example:
char*filename="C:\My Documents\Pictures\picture.bmp";
I am attempting to use the gdb/mi debugger in the Eclipse CDT version 6.02. While I am debugging I can step through the program with ease up until I reach the following snippet of a block of code.
ENUM_START_TYPE My_Class::some_function( const char * c, const char * e)
{
ENUM_START_TYPE result = GENERIC_ENUM_VALUE;
if ( c[0] == '<' )
{
result = do_something()
}
...
MORE CODE
...
return result;
}
When the debugger reaches this line.
if ( c[0] == '<' )
It starts exploring sections of code that it can not find until it opens a tab containing the /projectname/.metadata and simply declares:
"Resource '/project_name/.metadata' does not exist.
At which point the debugger terminates the program with no reason as to why.
All I wish to do is step over this line of code because it really is as trivial as comparing characters.
My question is: Why is this happening? Is it something to do with the debugger, or does it have something to do with my code, or what. Additionally, what is the .metadata and why can't the file be located and opened when it clearly exists (I can locate and open the .metafile without a problem).
Other info that may be pertinent: The files are located on a clearcase snapshot view, but are not checked into source control. I don't think that would cause an error like this, but clear case has caused so many random errors for me that I thought it would be worth mentioning.
Thanks in advance
As I am not aware of any side-effect a snapshot view might have in the process.
A dynamic view could consider part of the directories as "non-selected" (and then non-readable).
You have also the issue of symlink to dynamic view set on drive.
But a snapshot view is nothing more than a working tree on the hard drive.
To rule out any "ClearCase interference", you could try and debug your project entirely copied outside of any view of any sort (based on the content of your current snapshot view), and see if the problem persists.