c++ - Declaring a global in a global header file? -


I have a header file, say, common. H, which is included on many projects in all files. Actually I want to declare a global variable, eg .:

memory manager; DLL_EXPORT MemoryManager * gMemoryManager;

When I do this, I get many linker errors

class memory manager * Gmail Manager is already defined.

: (?

As you type each of the variables in each compiled file These are then collision on linking. Remember that the preprocessor reads in all the header files and creates a large file from all of them, so every time this big file is compiled, gMemoryManager has been made.

You need to use the extern and it is a non-header

  extern DLL_EXPORT MemoryManager  

One of your C ++ files

/ P>

  DLL_EXPORT MemoryManager * GmailReader;  

By the way I do not know what DLL_EXPORT does, I'm assuming that it needs to go to both places.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -