|
Are you absolutely sure it's malloc that's causing that error code (use SetLastError to reset the thread's error code immediately before the malloc call)?
If so, all I can suggest is single-stepping through malloc (you have got the CRT source installed haven't you?) in the debugger and seeing where it fails. It's not so tricky
I'm afraid I can't help further, as I haven't had VC6 installed anywhere for ages (and don't even know where I could lay my hands on the install media).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks, Stuart.
I will try stepping through again. But I find it more or less fruitless because I haven't a clue how the CRT operates, and I find it very difficult to read that code with all the underscores!
|
|
|
|
|
Can you build a new program that only uses malloc and see what happens.
If you view the assembly does malloc actually get called.
Can you post the code.
a programmer traped in a thugs body
|
|
|
|
|
Thanks for your interest.
I will look at the assembly as you suggest.
I can't post the code until I get to work tomorrow, but I'll do so if I can't solve it on my own.
|
|
|
|
|
me sathish
u r allocating more mem tht the system can't hold using malloc.
so only u can use heap functions to allocate more.
ya
|
|
|
|
|
Hello,
I am having a problem with setting up a necessary circular dependency.
I have a class (MessageHandler) which inherits from a "interface" as much as you're allowed to do that in c++. It also contains a queue (TaskQueue). and here is the circular bit: the TaskQueue needs a reference to the MessageHandler. The other catch is that the Tasks in TaskQueue need to know about the MessageHandler.
So the code goes like this (or at least the screwy parts):
(in MessageHandler.h)
#ifndef MESSAGE_HANDLER_H
#define MESSAGE_HANDLER_H
#include "TaskQueue.h"
class MessageHandler : public somenamespace:someclass {
private:
TaskQueue tq;
someobj& ref;
...
public:
MessageHandler (someobj& r) : ref (r) {
tq.setMessageHandler (&this);
..
}
};
#endif
(MessageHandler.C)
#include "MessageHandler.C"
..some functions making use of tq..
(in TaskQueue.h)
#ifndef TASK_QUEUE_H
#define TASK_QUEUE_H
#include "Tasks.h"
class MessageHandler;
class TaskQueue : public someotherclass {
private:
MessageHandler* msg_handler;
..other queue-things...
public:
TaskQueue () {...}
inline void setMessageHandler (const MessageHandler* mh) { msg_handler = mh; }
void doSomething () {
msg_handler->doSomething ();
}
};
#endif
(in Tasks.h)
#ifndef TASK_H
#define TASK_H
class MessageHandler;
class Task {
private:
MessageHandler* msg_h;
public:
Task (const MessageHandler* mh) {msg_h = mh;}
}
(int Tasks.C)
#include "Tasks.h"
void Task::someFunction () {
msg_h->someFunction ();
}
#endif
I am not sure if the forward declaration is right; do I need to include the ": public..." inheritance stuff?
Main is somewhere else, and it just does has:
#include "MessageHandler.h"
...
MessageHandler msg_handler;
...
that part is pretty standard.
The first couple of errors I get from the compiler (gcc) is:
./include/MessageHandler.h:18: error: declaration of âstruct TaskQueue::MessageHandlerâ
./include/Tasks.h:21: error: changes meaning of âMessageHandlerâ from âstruct MessageHandlerâ
./include/MessageHandler.h:21: error: field âtask_qâ has incomplete type
./include/MessageHandler.h:24: error: expected â,â or â...â before â:â token
....all hell breaks loose
Any help is appreciated!
|
|
|
|
|
It wouldn't be that you have:
(MessageHandler.C)
#include "MessageHandler.C"
when you meant #include MessageHandler.h ?
|
|
|
|
|
In the code I do have the latter not the prior.
just a typo from the code -> post transition. Thanks!
|
|
|
|
|
thelonesquirrely wrote: (in TaskQueue.h)
#ifndef TASK_QUEUE_H
#define TASK_QUEUE_H
#include "Tasks.h"
class MessageHandler; //forward declaration
It seems you don't understand the fundamental concept of a forward declaration. It provides the mechanism for the storage of a typed pointer without the inclusion of the header file.
In your post Tasks.h defines MessageHandler so the the inclusion of the header file negates the need to use a forward declaration.
class A{
void what(){ printf("hello"); }
};
class A;
class B{
A* myAPtr;
void myFunc();
};
#include "B.h"
#include "A.h"
void B::myFunc(){ myAPtr->what(); }
|
|
|
|
|
I compiled a large subset of the code you supplied in gcc 4.0.1 and found the following issues:
- In the Task constructor, you attempt to convert a const pointer to a non-const pointer - that's a no-no.
- In TaskQueue.h, you effectively have two forward declarations of MessageHandler (one in TaskQueue.h, one from #including Tasks.h) - that's not allowed, so remove the one in TaskQueue.h - you always #include Tasks.h, so you know you'll have the forward declaration from there.
- Again, in TaskQueue::setMessageHandler, you are converting a const pointer to a non-const pointer
- You forward declared MessageHandler in TaskQueue.h - therefore, you do not know what methods MessageHandler has, so you can't call them in the header (as you've done in TaskQueue::doSomething). You can only call them after you've got a complete declaration of MessageHandler (i.e. in a TaskQueue.C, after you've #included MessageHandler.h)
- You use '&this' in the MessageHandler constructor - this will give a MessageHandler**, as 'this' is a MessageHandler*
- Your Task class isn't terminated with a semi-colon. This *can* cause torrents of incomprehensible error messages...
Fix them and I suspect your compilation problems may go away.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You guys are awesome! thanks! Now I finally have a better understanding of the #include structure and forward declarations! Thanks!!!
|
|
|
|
|
Hi All,
I'm trying to create a new dialog in my .rc resource file and then create a C++ object using it. As far as I can tell, I'm doing it the same way that other dialogs have been implemented in this large legacy VC++ version 2.0 project, but I get
error C2065: 'WMM_DOOR_CONTROLS' : undeclared identifier
upon compiling the file that tries to create the object, from the following line:
WMMAuxIOSelectDial AuxIOCtrl (this, WMM_DOOR_CONTROLS);
As far as I can tell, the only place this identifier is declared is with the resource in the resource file; that is the only place the other dialogs' ids are found.
Obviously, there is a lot I don't know. Is there some kind of initial build step that I need to run to process the .rc file so that the identifier will be found in a generated file?
This line is in a file that hasn't had any other dialogs yet. Is there something else that needs to be added?
Do I need a .dlg file, as well, for this resource?
This is non-MFC, using SDK calls only.
I've tried a lot of small stuff with which I don't want to belabor this post, and I've done a lot of web searching, however I'm hoping there's something easy that I don't know about that I can try, and I haven't thoroughly searched all the MSDN and usenet posts, but I have put in about twelve hours of banging my head against this and I'll continue to search while awaiting any replies.
Much thanks for any help you can give me.
Here is my resource declaration:
---------------------
WMM_DOOR_CONTROLS DIALOG DISCARDABLE 200, 10, 162, 138
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Door Controls"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "",-1,"Static",SS_BLACKFRAME | WS_GROUP,10,9,141,97
PUSHBUTTON "&Cancel",IDCANCEL,66,115,30,14
PUSHBUTTON "Door 1",WMM_IDB_SEL_RELAY1,20,18,122,14
PUSHBUTTON "Door 2",WMM_IDB_SEL_RELAY2,20,40,122,14
PUSHBUTTON "Door 3",WMM_IDB_SEL_RELAY3,20,62,122,14
PUSHBUTTON "Door 4",WMM_IDB_SEL_RELAY4,20,83,122,14
END
---------------------
Should I also post my WMMAuxIOSelectDial class code?
Best regards,
|
|
|
|
|
I would expect your dialog identifier WMM_DOOR_CONTROLS DIALOG DISCARDABLE to be declared elsewhere, perhaps in a file resource.h which is #include d by both the .rc resource file and by the .h or .cpp file that uses the identifier. It's likely that its this last one you are missing.
To see what I mean you could use the Visual Studio wizard to create a new dialog based project then search to see where the identifier IDD_DIALOG1 is declared.
|
|
|
|
|
Hi Jonathan,
Thanks for your reply,
I searched *.* and *.h in my entire project, and the resource identifiers that compile successfully are not found. I have a set of files that builds, and I continually delete all object files and build those others successfully.
Could there be some other intermediary generated files that the build process is using in which the declarations have been satisfied, and the resource.h file that I need not checked out from my version control system and I never needed it because I had those intermediary files? This seems like a bit of a stretch.
I seem to have some resource files that have other names, such as w_resrc.h, but
I searched *.* and *.h and didn't find the working identifiers anywhere.
How in the world can those others be getting built successfully?
I'm using a really old, legacy compiler, and it can be regarded as me just writing the .rc file in a text editor. I use the VC++6.0 IDE to help me with this, but, as I say the other resource IDs all compile, and *they* are not declared anywhere else that I can reasonably see.
Best regards,
|
|
|
|
|
In my initialization,
WMMAuxIOSelectDial AuxIOCtrl (this, WMM_DOOR_CONTROLS);
WMM_DOOR_CONTROLS just had to be in quotes:
WMMAuxIOSelectDial AuxIOCtrl (this, "WMM_DOOR_CONTROLS");
Good one, eh? That was two days I didn't need to spend...
|
|
|
|
|
Glad to hear you got it sorted.
|
|
|
|
|
Sorry, I'm new in MFC...
I know that I can access CMyAppDoc within CMyAppView using GetDocument() function in a SDI Application. How can I do the inverse? that's access CMyAppView within CMyAppDoc?
Thank you masters!
|
|
|
|
|
I think the idea is that you don't need to. For instance if you are viewing a split document e.g. page 1 and page 7, when you ask for the view which one do you want?
You are meant to update the data your document contains e.g. a text or drawing then from the document call UpdateAllViews to have the view (or views) redraw/paint your document so you see the changes.
Also if the View knows about the document and the document the view it can get complicated with circular references.
|
|
|
|
|
You can use CDocument::GetFirstViewPosition and CDocument::GetNextView to iterate through all the views that are attached to a document.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
See CView Access From Anywhere[^] and questions on the bottom of page.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I would also point you at UpdateAllViews member function of the CDocument class.
As has been said, the whole point is that CDocument has no clue whatsoever about the views. This lets you replace / add different views, and only change one area of your code.
This is a GoodThing(tm).
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I have upgraded a project written in VC++ 7.1 version using the .net 2005 wizard. After fixing few code related issues, I have got the following errors while building
error LNK2001: unresolved external symbol DllCanUnloadNow
error LNK2001: unresolved external symbol DllGetClassObject
I have declared this in the .def file as
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
I would really appreciate for showing me the right way to resolve this please. Thanks in advance.
SoftwareDeveloper(.NET)
|
|
|
|
|
did you switch a dll from being a com DLL to a managed DLL?
a programmer traped in a thugs body
|
|
|
|
|
Few libraries actually was written in vc 6 and using those with that..but it has been upgraded to vc 7 ..
Thanks
SoftwareDeveloper(.NET)
|
|
|
|
|
Finaly I could resolve the issue. I have done the following steps to resolve the issue.
1) Have set "Multi-Threaded Debug(/MTD" in all the projects under workspace. this thing was correct already but mentioning here for future reference.
2) In the Resources-->Preprocessor Definitions , I have set "_DEBUG,_MT,DLL". I believe this part , corrected the issue. previously it was having only "_DEBUG".
Thanks,..
SoftwareDeveloper(.NET)
|
|
|
|
|