A
Adam Clauss
I have a few variables that I want declared as global. To accomplish this,
I made the files globals.h and globals.cpp.
In globals.h I have the declarations for the structs, and one variable
actually defined. It is defined w/ the extern keyword. Then, in
globals.cpp I actually define that extern variable. If my understanding of
this is correct, then by any file that needs access to this variable simply
needs to include globals.h right?
It seems to.. "sort-of" work. While everything compiles correctly, the
Intellisense does not pick any of this up. AKA: when I type in the name of
the one variable I defined and hit the period key, I do not get a list of
members as I should. Any ideas on this?
-----------globals.h-----------
#pragma once
struct XOrgDirectory
{
CString path;
bool searchSubs;
};
typedef CArray<XOrgDirectory> DirectoryArray;
struct XOrgConfig
{
DirectoryArray Directories;
};
extern XOrgConfig Config;
-----------globals.cpp-----------
XOrgConfig Config;
I have also tried declaring the structs in the following manner, but it made
no difference:
typedef struct
{
DirectoryArray Directories;
} XOrgConfig;
I am not sure which is considered "better."
Any suggestions?
I made the files globals.h and globals.cpp.
In globals.h I have the declarations for the structs, and one variable
actually defined. It is defined w/ the extern keyword. Then, in
globals.cpp I actually define that extern variable. If my understanding of
this is correct, then by any file that needs access to this variable simply
needs to include globals.h right?
It seems to.. "sort-of" work. While everything compiles correctly, the
Intellisense does not pick any of this up. AKA: when I type in the name of
the one variable I defined and hit the period key, I do not get a list of
members as I should. Any ideas on this?
-----------globals.h-----------
#pragma once
struct XOrgDirectory
{
CString path;
bool searchSubs;
};
typedef CArray<XOrgDirectory> DirectoryArray;
struct XOrgConfig
{
DirectoryArray Directories;
};
extern XOrgConfig Config;
-----------globals.cpp-----------
XOrgConfig Config;
I have also tried declaring the structs in the following manner, but it made
no difference:
typedef struct
{
DirectoryArray Directories;
} XOrgConfig;
I am not sure which is considered "better."
Any suggestions?