Re: Using a extern variable

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

From: Andre Oschadlin (dspipeline_at_hotmail.com)
Date: 12/06/04


Date: Mon, 6 Dec 2004 12:16:16 +1000

I would have created a class, say CGlobals, which all of your program can
include using an extern statement.

Then place all of your global variables within that class. Then you can
also do any special initialisation and clean up if needed using the CGlobals
constructor and destructor.

This also cleans up any linker errors. :-)

My guess is that you haven't actually defined the global variables anywhere,
but you just happened to have an 'int count' defined somewhere. Check for
where you've actually defined all of the variables.

Andre

"iLLiDaN" <iLLiDaN@discussions.microsoft.com> wrote in message
news:9FBDF155-CD77-45A9-88E9-B87AD593DC1C@microsoft.com...
> Hi, I need to use a global integer and CString variables in a project. I'm
> using EVC++. I have a globals.h where I put:
> //////////////////////
> #ifndef __GLOBALS__
> #define __GLOBALS__
> extern int count;
> extern CString StrComPort, name;
> #endif
> ////////////////////
>
> The "count" variable can be accessed from any dialogs, but the CString
> variables make a Link error.
>
> How Can I get a CString variable which is globall to all the project??
> Thank you!.



Relevant Pages

  • Re: alpha defined: virtualcnt,titleid,keyid,helplineid,pasteboardid
    ... > Where would I best find EXTERN and GLOBAL variables? ... Going back to the C sources: the definitions and (EXTERN) ... thus finding the header file. ... Another way would be to use the CTAGS program, which keeps trace ...
    (comp.os.vms)
  • Re: Use of extern keyword
    ... > i.e consider a following piece of code from MSDN explaining extern ... > void next ... > Here,if I drop the extern keyword from source file 2 and compile and ... in using global variables, it's much better practice to define the ...
    (comp.lang.c)
  • Re: Use of extern keyword
    ... >> i.e consider a following piece of code from MSDN explaining extern ... >> Here,if I drop the extern keyword from source file 2 and compile and ... > considered to be a tentative declaration. ... > in using global variables, it's much better practice to define the ...
    (comp.lang.c)
  • Re: initialization of local static variable
    ... in how i read global variables are "about external declarations" ... extern ... le variabili automatiche e quelle register, invece, hanno valori ...
    (comp.lang.c)
  • Re: exporting global variables from dynamically linked libraries
    ... > global variables that I am exporting. ... > declares the variables as extern. ... of those vars in your program and the linker first uses those before using ...
    (comp.os.linux.development.apps)