|
Hi all,
Sometimes I get runtime error in deleting the dynmically allocated object. I know the reasons. But how can I catch the exception during delete
Thanks in advance,
Sarvan AL
|
|
|
|
|
Most common type of problem is deleting an already deleted pointer.
You can check for null to avoid this...
if(pointer!=NULL)<br />
delete pointer;
Owner drawn
Jesus Loves
|
|
|
|
|
In C++ deleting a NULL pointer is a NOP - It is fine to do so.
You comment about a double delete is correct but only works if you NULL it after deleting it:
CSomeObject* pObj = SomeFunction();<br />
delete pObj;<br />
pObj = NULL;
delete pObj;
Steve
|
|
|
|
|
Thanks mate.
Owner drawn
Jesus Loves
|
|
|
|
|
Hello,
Did you try the following:
try
{
delete a;
}
catch( ... )
{
std::cout << "Caught exception!" << std::endl;
}
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hi all,
I am using NI graph in some application .I need to get the height and width of the plot area of the graph like not the controls height and width its on the control some area will be used to plot the graph .I used the line below but its returning zero is there any alternative mathod
long lHeight = GraphPtr->GetPlotAreaImage().GetHeight();
"Men never do evil so completely and cheerfully as when they do it from religious conviction"
-Pascal
|
|
|
|
|
chethu665 wrote: NI graph in some application
I believe you are rfering to National Instrument Graphs.. if am right! there loads of graph samples present at there site! also they provide forums for same
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I have ported an application from vc to vc.net. While the application runs properly in vc it is crashing in release mode(debug is running correctly) in vc.net.
can any one pls. help what exactly could be the probable problem.
---Arun.
|
|
|
|
|
Hi,
I am lnking a static library in my application. On linking i am getting the following errors. I compiled my application with /MDd and /MD switches.
This is errors text that i am getting on building my application.
Created directory: release
cl -GX -TP -DNDEBUG -O2 -G6 -nologo -c -MDd -MD -verbose -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/main.obj main.cpp
main.cpp
cl -GX -TP -DNDEBUG -O2 -G6 -nologo -c -MDd -MD -verbose -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/SBjsiCreateResourceTest.obj SBjsiCreateResourceTest.cpp
SBjsiCreateResourceTest.cpp
cl -GX -TP -DNDEBUG -O2 -G6 -nologo -c -MDd -MD -verbose -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/SBjsiDestroyResourceTest.obj SBjsiDestroyResourceTest.cpp
SBjsiDestroyResourceTest.cpp
cl -GX -TP -DNDEBUG -O2 -G6 -nologo -c -MDd -MD -verbose -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/SBjsiInitTest.obj SBjsiInitTest.cpp
SBjsiInitTest.cpp
cl -GX -TP -DNDEBUG -O2 -G6 -nologo -c -MDd -MD -verbose -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/SBjsiShutDownTest.obj SBjsiShutDownTest.cpp
SBjsiShutDownTest.cpp
link -nodefaultlib:msvcrt.lib -nodefaultlib:msvcrtd.lib -nodefaultlib:libcd.lib -nologo -machine:I386 -incremental:no -fixed:no -MAP kernel32.lib user32.lib advapi32.lib UnitTestDriver.lib -out:release\Jsi.exe -release -libpath:"d:\openvxi\lib" VXIlog.lib VXIjsi.lib UnitTestDriver.lib xerces-c_2.lib -libpath:"d:\openvxi/lib" -libpath:"c:\xerces-c-src_2_6_0/lib" -libpath:"d:\openvxi/test/lib" @C:\DOCUME~1\050343\LOCALS~1\Temp\nma01800.
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
SBjsiShutDownTest.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(test.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
main.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
SBjsiCreateResourceTest.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
SBjsiDestroyResourceTest.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
SBjsiInitTest.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol __except_list
SBjsiShutDownTest.obj : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(test.obj) : error LNK2001: unresolved external symbol __except_list
main.obj : error LNK2001: unresolved external symbol __except_list
SBjsiCreateResourceTest.obj : error LNK2001: unresolved external symbol __except_list
SBjsiDestroyResourceTest.obj : error LNK2001: unresolved external symbol __except_list
SBjsiInitTest.obj : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol _atexit
UnitTestDriver.lib(testregistry.obj) : error LNK2001: unresolved external symbol _atexit
UnitTestDriver.lib(test.obj) : error LNK2001: unresolved external symbol _atexit
SBjsiCreateResourceTest.obj : error LNK2001: unresolved external symbol _atexit
SBjsiDestroyResourceTest.obj : error LNK2001: unresolved external symbol _atexit
SBjsiInitTest.obj : error LNK2001: unresolved external symbol _atexit
SBjsiShutDownTest.obj : error LNK2001: unresolved external symbol _atexit
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
SBjsiCreateResourceTest.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
SBjsiDestroyResourceTest.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol __imp__exit
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol __imp__sprintf
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol __imp__sprintf
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol __imp__sprintf
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol __fltused
UnitTestDriver.lib(test.obj) : error LNK2001: unresolved external symbol __purecall
msvcprt.lib(delop_s.obj) : error LNK2001: unresolved external symbol _free
release\Jsi.exe : fatal error LNK1120: 10 unresolved externals.
Where UnitTestDriver.lib is the static library that we built.
Please do let me know what i need to do.
Regards, Eswari
Subramanyeswari
|
|
|
|
|
-MDd and -MD are mutually exclusive flags - you can't specify both of them. Use -MDd to specify a multithreaded debug build, and -MD to specify a multithreaded release build.
If you use -MDd, you'll need to ensure you're linking against MSVCRTD.LIB , -MD requires MSVCRT.LIB
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thank for your reply Ryan,
But it did not work. This is the output i got. As you suggested i changed my make as:
# /Od disable optimizations
CFLAGS_DEBUG = -D_DEBUG -Od -Zi -Fd$(TARGET).pdb -MDd
# /O2 optimize for speed
# /G6 generate code for Pentium Pro
CFLAGS_RELEASE = -DNDEBUG -O2 -G6 -MD
..
And i compiled taking release option and this is the output. What i am missing here.
Created directory: release
cl -GX -TP -DNDEBUG -O2 -G6 -MD -nologo -c -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/main.obj main.cpp
main.cpp
cl -GX -TP -DNDEBUG -O2 -G6 -MD -nologo -c -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/SBjsiCreateResourceTest.obj SBjsiCreateResourceTest.cpp
SBjsiCreateResourceTest.cpp
cl -GX -TP -DNDEBUG -O2 -G6 -MD -nologo -c -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/SBjsiDestroyResourceTest.obj SBjsiDestroyResourceTest.cpp
SBjsiDestroyResourceTest.cpp
cl -GX -TP -DNDEBUG -O2 -G6 -MD -nologo -c -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/SBjsiInitTest.obj SBjsiInitTest.cpp
SBjsiInitTest.cpp
cl -GX -TP -DNDEBUG -O2 -G6 -MD -nologo -c -W3 -DWIN32 -YX -Fprelease\Jsi.pch -Forelease/SBjsiShutDownTest.obj SBjsiShutDownTest.cpp
SBjsiShutDownTest.cpp
link -nodefaultlib:msvcrt.lib -nodefaultlib:msvcrtd.lib -nodefaultlib:libcd.lib -nologo -machine:I386 -incremental:no -fixed:no -MAP kernel32.lib user32.lib advapi32.lib UnitTestDriver.lib -out:release\Jsi.exe -release -libpath:"d:\openvxi\lib" VXIlog.lib VXIjsi.lib UnitTestDriver.lib xerces-c_2.lib -libpath:"d:\openvxi/lib" -libpath:"c:\xerces-c-src_2_6_0/lib" -libpath:"d:\openvxi/test/lib" @C:\DOCUME~1\050343\LOCALS~1\Temp\nma01888.
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
SBjsiShutDownTest.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(test.obj) : error LNK2001: unresolved external symbol ___CxxFrameHandler
main.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
SBjsiCreateResourceTest.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
SBjsiDestroyResourceTest.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
SBjsiInitTest.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol __except_list
SBjsiShutDownTest.obj : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(test.obj) : error LNK2001: unresolved external symbol __except_list
main.obj : error LNK2001: unresolved external symbol __except_list
SBjsiCreateResourceTest.obj : error LNK2001: unresolved external symbol __except_list
SBjsiDestroyResourceTest.obj : error LNK2001: unresolved external symbol __except_list
SBjsiInitTest.obj : error LNK2001: unresolved external symbol __except_list
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol _atexit
UnitTestDriver.lib(testregistry.obj) : error LNK2001: unresolved external symbol _atexit
UnitTestDriver.lib(test.obj) : error LNK2001: unresolved external symbol _atexit
SBjsiCreateResourceTest.obj : error LNK2001: unresolved external symbol _atexit
SBjsiDestroyResourceTest.obj : error LNK2001: unresolved external symbol _atexit
SBjsiInitTest.obj : error LNK2001: unresolved external symbol _atexit
SBjsiShutDownTest.obj : error LNK2001: unresolved external symbol _atexit
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
SBjsiCreateResourceTest.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
SBjsiDestroyResourceTest.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
UnitTestDriver.lib(testresult.obj) : error LNK2001: unresolved external symbol __imp__exit
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol __imp__sprintf
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol __imp__sprintf
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol __imp__sprintf
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol __fltused
UnitTestDriver.lib(test.obj) : error LNK2001: unresolved external symbol __purecall
msvcprt.lib(delop_s.obj) : error LNK2001: unresolved external symbol _free
release\Jsi.exe : fatal error LNK1120: 10 unresolved externals
Please help me..
Regards
|
|
|
|
|
subramanyeswari wrote: -nodefaultlib:msvcrt.lib
As I said, you need to ensure you're linking against MSVCRT.LIB if you're compiling with -MD. This line is forcing the compiler to ignore this library. Remove this flag and try again.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thank you.. I think that worked. But i think there is one more problem. Let me figure out. It i cannot solve it.. I will disturb you again.
Anyway Thank you very much.
|
|
|
|
|
I am able to successfuly build my application when i link with my static library (which is built in debug option). But unfortunately i am not able to successfully execute my application when i link with static library(which is built in release mode). When i am debugging it is giving the following error
user breakpoint called from code 0x77f9193c.
Any help in this regard
Eswari
|
|
|
|
|
Sorry for disturbing you people again. I took another root. I built my static library and linked with the application. This time no /MDd or /MD flags.
When i am trying to link i am getting the following errors:
Created directory: debug
cl -GX -TP -D_DEBUG -Od -Zi -Fddebug\JsiD.pdb -nologo -c -W3 -DWIN32 -YX -Fpdebug\JsiD.pch -Fodebug/main.obj main.cpp
main.cpp
cl -GX -TP -D_DEBUG -Od -Zi -Fddebug\JsiD.pdb -nologo -c -W3 -DWIN32 -YX -Fpdebug\JsiD.pch -Fodebug/SBjsiCreateResourceTest.obj SBjsiCreateResourceTest.cpp
SBjsiCreateResourceTest.cpp
cl -GX -TP -D_DEBUG -Od -Zi -Fddebug\JsiD.pdb -nologo -c -W3 -DWIN32 -YX -Fpdebug\JsiD.pch -Fodebug/SBjsiDestroyResourceTest.obj SBjsiDestroyResourceTest.cpp
SBjsiDestroyResourceTest.cpp
cl -GX -TP -D_DEBUG -Od -Zi -Fddebug\JsiD.pdb -nologo -c -W3 -DWIN32 -YX -Fpdebug\JsiD.pch -Fodebug/SBjsiInitTest.obj SBjsiInitTest.cpp
SBjsiInitTest.cpp
cl -GX -TP -D_DEBUG -Od -Zi -Fddebug\JsiD.pdb -nologo -c -W3 -DWIN32 -YX -Fpdebug\JsiD.pch -Fodebug/SBjsiShutDownTest.obj SBjsiShutDownTest.cpp
SBjsiShutDownTest.cpp
link -nodefaultlib:libcd.lib -nodefaultlib:msvcrtd.lib -nodefaultlib:msvcrt.lib -nologo -machine:I386 -incremental:no -fixed:no -MAP kernel32.lib user32.lib advapi32.lib UnitTestDriver.lib -out:debug\JsiD.exe -debug -pdb:debug\JsiD.pdb -release -libpath:"d:\openvxi\lib" VXIlogD.lib VXIjsiD.lib UnitTestDriverD.lib xerces-c_2D.lib -libpath:"d:\openvxi/lib" -libpath:"c:\xerces-c-src_2_6_0/lib" -libpath:"d:\openvxi/test/lib" @C:\DOCUME~1\050343\LOCALS~1\Temp\nma01068.
LINK : warning LNK4049: locally defined symbol "_exit" imported
UnitTestDriver.lib(vostring.obj) : error LNK2001: unresolved external symbol __imp__sprintf
UnitTestDriver.lib(success.obj) : error LNK2001: unresolved external symbol __imp__sprintf
UnitTestDriver.lib(failure.obj) : error LNK2001: unresolved external symbol __imp__sprintf
debug\JsiD.exe : fatal error LNK1120: 1 unresolved externals
when i looked for the documentation one article says when you are trying to link with static and also linking with libc.lib you will get the following problems.
So what should i do.
Regards, Eswari
|
|
|
|
|
It appears that your project settings are set to use the shared C library, but you're linking against the static C library.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
How to change my project settings to inform that i am linking against static library.
Regards, Eswari
|
|
|
|
|
Hi All VC guru's
It is my first posting on code project . I came to know about this forum through my friend.
My probles is that I developed a application GsrApp using VC++ .NET 2003. This application runs fine on Windows 2000 , Windows 2003 & Window Xp home or professional . But yesterday I tried to run the same application on Windows 98 and Windows ME . But when I tried to run it got error :
GsrApp.exe caused invalid page fault in module user.exe
I coould not get through this problem because I cannot install VC++ .NET 2003 on Windows 98 or Windows ME as it could only be installed on Windows X, Windows 2000 & Windows 2003 . Hence couldnt formulate any way to debug my application on Windows 98 or ME . Please some Guru help me to get out of this problem . And tell me why I am failing on Windows 98 or ME
Singh, G
|
|
|
|
|
Is your application using Unicode?
|
|
|
|
|
Thanks for replying George , My application uses MBCS . What do you think should I use unicode for Windows 98 . And just for your information that I am also using adobe 5.0 libraries in my application.
Thanks
-- modified at 11:37 Friday 10th February, 2006
|
|
|
|
|
Hello All,
I am using a CListCtrl created in a dialog window. This CListCtrl displays thumbnail images.
I want a notification when a user double clicks an image in list. The OnLButtonDblClk function only works when user double clicks in the dialog window. It does not catch the event when a user double clicks in the list control window, probably because the dialog treats list control as a separate window.
Can anyone please let me know how do I write a event handler to to catch the event when an image in CListCtrl is double clicked.
Thanks in advance for your reply.
Abhijit Deshmukh
|
|
|
|
|
Override your own list control like CMyListCtrl from CListCtrl.
Enjoy
|
|
|
|
|
The listview control sends a NM_DBLCLK notification to its parent window when the user double-clicks in it. You can listen for this.
|
|
|
|
|
Hi
My VS 6.0 can not compile the unicode resource file. Who solved this problem?
Thanx.
|
|
|
|
|