|
I do not know enough to answer your question, but I would look at whether the main program thread is still running when you are shutting down the DLL as the functions in the DLL are mapped to the process space and use the stack of the calling thread.
To really know what is happening I recommend that you pick up a copy of "Programming Applications for Microsoft Windows" by Jefferey Richter (absolutly the best source of information).
Good Luck!
INTP
Every thing is relative...
|
|
|
|
|
I suspect the problem is caused by trying to call FreeLibrary from the DllMain of the main DLL - Destructors for global C++ objects in a DLL are called from DllMain . Basically in a DllMain function the system holds the "loader lock" so you can't call any function that requires this lock. That's why you're only meant to do simple initialization in DllMain : Calling LoadLibrary or FreeLibrary from DllMain is definitely out of the question. As mentioned earlier this means that in a DLL you can't call LoadLibrary or FreeLibrary from the constructor or destructor of a class that has a global instance.
Steve
|
|
|
|
|
Thanx for your advice.
Though I solved my problem in other ways, I think I have to explore about DLL little more and with reference to your message I will proceed.
Regards
Anil
|
|
|
|
|
I am writing an application that includes communications over RS232 with a terminal window.
CEditWiew looks great because I need copy and paste etc. but it's wrapping is done on a whole word basiss rather than character at a time.
Is there an option that would provide character at a time wrapping rather than deriving my own class from CScrollView?
Thanks.
Elaine
The tigress is here
|
|
|
|
|
Look at the EM_SETWORKBREAKPROC message and implement your own EditWordBreakProc() function to do the custom word breaks. Just break wherever you like. It might require a bit of trickery to work out where to put the breaks. You can categorise every character as a delimiter and let the edit control work out where to put the breaks - this should do the trick.
<edit>Oops... should be EM_SETWORDBREAKPROC not EM_SETWORDBREAK </edit>
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"
-- modified at 0:25 Friday 7th April, 2006
|
|
|
|
|
|
HI
i wanna the code of TOERS OF HANOI with graplical user interface GUL
|
|
|
|
|
|
Ooh homework
You are meant to do it yourself, that's how you learn.
If you have specific problems in the course of the homework then ask.
Elaine
The tigress is here
|
|
|
|
|
|
why not declare T_UserThread() function in SocketHandling.h?
----------
best regards
|
|
|
|
|
include header files in .cpp files and use forward declaration in .h files.
-Saurabh
|
|
|
|
|
Excuse me if I am a little confused, but I did not see a reference to T_UserThread() any where in SocketHandling.h.
If you must place the actual code for T_UserThread() in the header instead of a source code file, then you should mark it as inline. If you do not then you will get a whole lot of redefinition errors, because each source code file that includes the header will have its own copy of the function.
Another solution to such problems, at least when dealing with classes, is to use forward declarations. A forward declaration is sort of like a prototype, only for classes instead of functions.
If all else fails, then move the code for T_UserThread() into a source code file and just place a prototype in the SocketHandling.h header as well as the Globals.h header. I do not recommend this solution but it will work, you just have to make sure that both prototypes are well commented so that you know there are two of them.
Good Luck!
INTP
Every thing is relative...
|
|
|
|
|
Alright... I put a prototype at the beginning of SocketHandling.h for T_UserThread(...) , then I put the function in server.cpp and Globals.h, and now I get these errors:
Globals.h(30): error C2065: 'network' : undeclared identifier<br />
Globals.h(30): error C2065: 'network' : undeclared identifier<br />
Globals.h(30): error C2228: left of '.UserThread' must have class/struct/union type<br />
type is ''unknown-type''<br />
Globals.h(30): error C2228: left of '.UserThread' must have class/struct/union type<br />
type is ''unknown-type''<br />
server.cpp(48): error C2084: function 'int T_UserThread(void *)' already has a body<br />
server.cpp(50): error C2228: left of '.UserThread' must have class/struct/union type<br />
type is ''unknown-type''<br />
server.cpp(50): error C3861: 'network': identifier not found, even with argument-dependent lookup<br />
server.cpp(60): error C2228: left of '.Start' must have class/struct/union type<br />
type is ''unknown-type''<br />
server.cpp(60): error C3861: 'network': identifier not found, even with argument-dependent lookup<br />
server.cpp(75): error C2228: left of '.FindConnections' must have class/struct/union type<br />
type is ''unknown-type''<br />
server.cpp(75): error C3861: 'network': identifier not found, even with argument-dependent lookup<br />
SocketHandling.cpp(194): warning C4312: 'type cast' : conversion from 'long' to 'char *' of greater size<br />
SocketHandling.cpp(199): warning C4312: 'type cast' : conversion from 'long' to 'char *' of greater size<br />
SocketHandling.h(65): error C2371: 'network' : redefinition; different basic types<br />
SocketHandling.h(65): error C2371: 'network' : redefinition; different basic types
What am I doing wrong? Thanks!
BTW: I updated the files.
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
I am not sure exactly what you did, but I did forget to mention that you should not be declaring global variables in your header files. If you need a global variable like network, then you should declare it in one of your source files and then place the same statement in the globals header file [or some other header] with the prefix "extern".
Example:
// in sorce file
MyClass network;
// in header file
extern MyClass network.
As for error C2084, that is exactly why the function should be in a source file. It sound like you still have two copies of the same function, are you sure you replaced it with a prototype in the header. Because if you did not then this is exactly the type of error message you would get.
Most of the errors you seem to be getting stem from the first error. If you solve the first error then most of them will go away.
I can not go to your code link from within this page, but I will post an example of the T_UserThread() function written as an inline template. It will not help you solve your current poblem, but it will give you something else to think about as far as design is concerned. After all I believe most of your problems are the result of design issues.
INTP
Every thing is relative...
|
|
|
|
|
Template<class playertype=""> inline
int T_UserThread(PlayerType* np)
{
network.UserThread(*np);
}
// Or better yet
Template<class playertype=""> inline
int T_UserThread(PlayerType& np)
{
network.UserThread(np);
}
Both of these versions are called just like any other function, but they are type safe. That is the compiler check generates the proper function and checks the arguments at compile time. Of course I do not know why you where using a void pointer in the first place. You seemed to know what the type being passed was and therefore passing a void made no since.
Also why bother even creating the function T_UserThread() as all it needs to do is call network.UserThread(), and since network is already a global variable you can just make the call directly and it will still be clear what you are doing in your code.
INTP
Every thing is relative...
|
|
|
|
|
i read your code.
1)try to add declare:
int T_UserThread(void * np);
before
#include "SocketHandling.h"
in Globals.h
and do somethig similar to this for other files if neccessary.
2)u must add keyword
inline
for the function in Globals.h, this is syntax requires.
A special image tool for Windows C++ programmers, don't miss it!
The world unique Software Label Maker is waiting for you and me ...
A nice hyper tool for optimizing your Microsoft html-help contents.
|
|
|
|
|
I recommend you rethink the layout of your header files. Header files should never need to include each other.
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"
|
|
|
|
|
The problems he is having do stem for poor design and a lack of understanding some of the C/C++ basics. I have seen header files that include each other, a very bad idea, but they usualy solve the problems that presents with forward declarations and the like.
INTP
Every thing is relative...
|
|
|
|
|
John R. Shaw wrote: I have seen header files that include each other, a very bad idea, but they usualy solve the problems that presents with forward declarations and the like.
IMO, if header files need include each other, then their contents either belong together in the same header file, or need to be separated into more header files so you have more fine-grained control.
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"
|
|
|
|
|
I agree with you one hundred percent! To be honest it has been some years since I have seen the subject come up. I can not even remember if I have ever made that mistake in design.
INTP
Every thing is relative...
|
|
|
|
|
John R. Shaw wrote: I can not even remember if I have ever made that mistake in design.
I have . I quickly rectified it once I realised I had though
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"
|
|
|
|
|
Seen a #include "stdafx.h" lately, and what stdafx.h contains?
What I DON'T like about that rule is, I locate a header file with a particular function, and I spend the next twenty mintues including about 20 more header files to resolve all the type definitions, data structures, base types and other crap required to use the function from the first header.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Sorry for the delay, I was entertaining myself with a Pokemon game...
Anyways... Yeah, now I'm getting an error saying that the network variable was already declared in server.obj... What?! It ain't on server.cpp... How can it be on the obj file? The only declaration I can find is this one:
} network; (after the class declaration)
Why is it already declared on server.obj? Dang... Thanks!
BTW: I have removed Globals.h, and there's no more includes depending on each other...
Maybe I am doing it right, but it's a problem with SDL or SDL_net?
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 21:18 Monday 10th April, 2006
|
|
|
|
|
If you declare a variable in a header file and include that header file into more than one source file, then you will get the 'already declared' types of errors and warnings.
It is best to ONLY define the variable in a single header file and declare an instance of the variable in a single source file.
For example, your header file 'SuperDuperClass.H' would have something like this in it:
// this is the instance definition, leting oter source files know there is
// a variable g_MySuperDuperClass of type SuperDuperClass out there somewhere
extern SuperDuperClass g_MySuperDuperClass;
And a single source file somewhere in your project would have this near the top:
#include "SuperDuperClass.H"
// this is the instance declaration
SuperDuperClass g_MySuperDuperClass;
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|