Global Instance

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Matthew Jakeman (m.jakeman_at_nospam.lancaster.ac.uk)
Date: 07/25/04


Date: Sun, 25 Jul 2004 16:32:37 +0100

Hi again, I have been trying to make the application Instance truly global
(ie declaring it in my applications main header file for use in seperate C++
files). It works fine the way tha app is initially set up with it being made
global only to the C++ file that is initially created but when i try to make
it truly global I get the compilation error :

StdAfx.obj : error LNK2005: "struct HINSTANCE__ * g_hInst"
(?g_hInst@@3PAUHINSTANCE__@@A) already defined in mclient.obj

stdafx.h is included from both dlgprocs.cpp and mclient.cpp, the two C++
files I wish to use it from at present, and stdafx.h includes the file
mclient.h (the header file containing the global definition of g_hInst). I
believe this may be a problem regarding the way C++ handles includes
differently to C ? I haven't done much C++ before and my application is
basically written in C as this is what I am used to and I am not at all
familiar with the C++ standard, if anyone could point out how this could be
solved or point me in the right direction of any help it would be greatly
appreciated!
Thanks in advance.
Matt



Relevant Pages

  • Re: static function declaration in header file
    ... >> Is there any reason for declaring functions as static in a header file ... >> called in the source file. ... >> The functions are declared static as an optimization. ... What overhead is saved by declaring the functions static? ...
    (comp.lang.c)
  • Re: static function declaration in header file
    ... > Is there any reason for declaring functions as static in a header file ... > compiler throws a warning for every such function declared but not ... What overhead is saved by declaring the functions static? ...
    (comp.lang.c)
  • Re: static function declaration in header file
    ... >Is there any reason for declaring functions as static in a header file ... What overhead is saved by declaring the functions static? ... I may still be sleepy this morning, but I can't think of any reason to ... Balmer Consulting ...
    (comp.lang.c)
  • static function declaration in header file
    ... Is there any reason for declaring functions as static in a header file ... argument is not a good solution since extern functions have additional ... What overhead is saved by declaring the functions static? ...
    (comp.lang.c)
  • using swig/tcl for 3rd party packages
    ... I have a 3rd party product which is meant to be linked with a user's c ... The product supplies a header file for ... applications much quicker. ... I've managed to build a swig "wrapper" file by simply using the ...
    (comp.lang.tcl)