|
Hi to all.
When I run my application and start to work with it, after a while it crashes!
Call stack:
00000000()
AfxCallWndProc(CWnd * 0x003af188 {CWnd hWnd=0x00020ae4}, HWND__ * 0x00020ae4, unsigned int 0x00000363, unsigned int 0x00000001, long 0x00000000) line 215 + 26 bytes
CWnd::SendMessageToDescendants(HWND__ * 0x00020ac6, unsigned int 0x00000363, unsigned int 0x00000001, long 0x00000000, int 0x00000001, int 0x00000001) line 2309
CWnd::SendMessageToDescendants(HWND__ * 0x00020ac8, unsigned int 0x00000363, unsigned int 0x00000001, long 0x00000000, int 0x00000001, int 0x00000001) line 2320
CWnd::SendMessageToDescendants(HWND__ * 0x000d09fc, unsigned int 0x00000363, unsigned int 0x00000001, long 0x00000000, int 0x00000001, int 0x00000001) line 2320
CWnd::SendMessageToDescendants(HWND__ * 0x0008099e, unsigned int 0x00000363, unsigned int 0x00000001, long 0x00000000, int 0x00000001, int 0x00000001) line 2320
CWnd::SendMessageToDescendants(unsigned int 0x00000363, unsigned int 0x00000001, long 0x00000000, int 0x00000001, int 0x00000001) line 146 + 32 bytes
CServisiApp::OnIdle(long 0x00000000) line 3694
CWinThread::Run() line 472 + 30 bytes
CWinApp::Run() line 400
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0b, int 0x00000001) line 49 + 11 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0b, int 0x00000001) line 30
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! 7c817077()
The error I get is: "First-chance exception in MyApp.exe: 0xC0000005: Access Violation."
Any clue?
Win XP, VC 6
Thanks!
|
|
|
|
|
You should have realized that this is the right time to add some log/traces/Messageboxes at places where you "expect"(blind guess-depends on how much steps in your application have executed already) your application to crash. Also read about the first chance exception handling mechanism here[^] and here[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
I'm aware of this.
The thing is there's no pattern when my app will crash, some times on this occasion and on second run on that. No relationship between?! That's what bugging me!
|
|
|
|
|
josip cagalj wrote: The thing is there's no pattern when my app will crash, some times on this occasion and on second run on that. No relationship between?!
But you should still add some gratuitous "logging" code to help narrow it down. Try and remove (unnecessary) parts of your code until the crash subsides.
There is no "silver bullet" for this. Roll up your sleeves and get dirty.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Yes so I did.
Found out the thing causing the problem. You see I inherited this app from an colleague from work he had slight different control then my own (it's work internal control we use). When overwritten, all worked OK.
The thing causing the problem is when called OnIdle message notifies some wnd's of an idle time, and some of those aren't wnd at all!
|
|
|
|
|
I work with DevC++ and i want to make a project with several c++ files.
For example i have two c++ files with two main(). Is it possible? How can i build (run) this? - it takes me an error message.
(
I have seen a project with two main but it is created in visual c++ not in devc++
and he build very well and every .cpp file generate it's .exe file (program for client server)
When i try to create the same project in Dev C++ i can't build!!!
What can i do?
)
Thank you!
|
|
|
|
|
A executable with two main methods ? It doesn't make a lot of sense to me: when it is executed, which function should be called ?
|
|
|
|
|
agetina wrote: For example i have two c++ files with two main(). Is it possible? How can i build (run) this? - it takes me an error message.
You application must have just one entry point. What is the purpose of two main() functions?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You can only have one main() function.
If you want 2 operation modes, you can control it via a start parameter one the commando line which got operated in your one and only main() function.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
You cannot have two main functions (main function is the entry point). You can, however, run an additional thread.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I can read the prototypes for windows.h in the include folder (I have installed dev c++) but i want a list of explained functions. I don't know for what to use each of them.
Thank you!
modified on Wednesday, June 3, 2009 4:29 AM
|
|
|
|
|
but i want a list of explained functions.
what do you mean by this???
|
|
|
|
|
Well, usually you don't need to read the explanations of all Win32 API functions in order to be a developer. Anyway (you know) you may find help for each and every function online, for instance searching for EncodePointer (the first function I found in winbase.h ) gives [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Look on MSDN - the best way is to Google for function-name site:msdn.microsoft.com . For example - what does CreateFile do? Just Google for CreateFile site:msdn.microsoft.com .
Anyway - as I said to you yesterday[^], you're going about this backwards. Start with the MSDN documentation (which tells you all about the function definitions) and then find the function prototype in the header files (although why even do that except when compiling code?!)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am trying to create a dll. During compilation,i get the folowing linking error.
"error LNK2001: unresolved external symbol"
How can i resolve it?
Thanks,
|
|
|
|
|
Giving more information would help us a lot. What is this symbol ? A variable, a function ? How is it declared ? ...
Please, provide as much useful information as possible.
|
|
|
|
|
It is a function.I declared that function in def file.
|
|
|
|
|
Are you scared to provide useful information or what ?
Where is this function coming from, how is it defined, .... ?
|
|
|
|
|
Actually the complete error message should be more informative. For instance, it should report what symbol is not resolved. Hence, please have a better look at the error message (and report here if you're still in troubles).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
This is the complete error message:
COM.def : error LNK2001: unresolved external symbol GetSignalValue()
Release/COM.lib : fatal error LNK1120: 1 unresolved externals
LINK : fatal error LNK1141: failure during build of exports file
|
|
|
|
|
Is GetSignalValue one of the functions of your library (I suppose it is, however maybe you're using also external libraries)? How is it declared and defined? Please show us the relevant code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am not using any external libraries.
In .def file:
; COM.def : Declares the module parameters for the DLL.
LIBRARY "COM"
DESCRIPTION 'COM Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
; COM.cpp Ordinal Numbers 100 - 110
GetSignalValue() @102
In .cpp file:
// COM.cpp: implementation of the CLogger class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "COM_1.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCOM::CCOM()
{
}
int FAR PASCAL GetSignalValue(int m_lCurValue)
{
long lReturnValue = m_lCurValue;
m_lCurValue += 10;
return lReturnValue;
}
In .h file:
// COM_1.h: interface for the CCOM class.
//
//////////////////////////////////////////////////////////////////////
class CCOM
{
public:
CCOM();
};
|
|
|
|
|
If you're using a C++ compiler (and probably you areusing it) then you should use the extern "C" construct to avoid C++ symbol mangling.
i.e.
extern "C"
{
int FAR PASCAL GetSignalValue(int m_lCurValue);
} and
extern "C"
{
int FAR PASCAL GetSignalValue(int m_lCurValue)
{
}
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks to all. I resolved that error. I declared the function in def as
GetSignalValue().It should be GetSignalValue.
|
|
|
|
|
Roay wrote: int FAR PASCAL GetSignalValue(int m_lCurValue)
Declare that as extern "C" - otherwise, the object file will export the C++ mangled name, not the unmangled name your DEF file expects to see.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|