Click here to Skip to main content
16,004,452 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Question about global variables in C/C++. Pin
Dangleberry20-Aug-03 22:35
sussDangleberry20-Aug-03 22:35 
GeneralRe: Question about global variables in C/C++. Pin
Dangleberry20-Aug-03 22:36
sussDangleberry20-Aug-03 22:36 
GeneralRe: Question about global variables in C/C++. Pin
George221-Aug-03 2:10
George221-Aug-03 2:10 
GeneralRe: Question about global variables in C/C++. Pin
G. Steudtel21-Aug-03 0:36
G. Steudtel21-Aug-03 0:36 
GeneralRe: Question about global variables in C/C++. Pin
George221-Aug-03 2:08
George221-Aug-03 2:08 
GeneralRe: Question about global variables in C/C++. Pin
Maxwell Chen21-Aug-03 2:22
Maxwell Chen21-Aug-03 2:22 
GeneralRe: Question about global variables in C/C++. Pin
George221-Aug-03 2:32
George221-Aug-03 2:32 
GeneralRe: Question about global variables in C/C++. Pin
Maxwell Chen21-Aug-03 2:52
Maxwell Chen21-Aug-03 2:52 
Well, from the view of the C++ linker, my previous example code would be something like this:

[the whole pseudo code in one single source file]
/* First, the compiler compiles main.cpp. It embeds the content of the included *.h files into main.cpp */

int iGlobalNumber;

void main()
{
    iGlobalNumber = 2;
}

/* Then, the compiler compiles mod.cpp. It embeds the content of the included *.h files into mod.cpp */

int iGlobalNumber; // Again because the #include "mod.H", this is why already defined.

void Test()
{
    iGlobalNumber = 1;
}


Regarding to the above issue, you may have a look at chapter 9 or 10 (I forgot) in the book "The C++ Programming Language" 3rd edition by Bjarne Stroustrup.

George2 wrote:
(?iGlobalNumber@@3HA)

C++ uses mangled names to serve polymorphism, overloading, etc.
You can take a look at this link: C++ Name Mangling/Demangling[^]

BuggyMax
GeneralRe: Question about global variables in C/C++. Pin
George221-Aug-03 3:03
George221-Aug-03 3:03 
GeneralRe: Question about global variables in C/C++. Pin
Maxwell Chen21-Aug-03 3:30
Maxwell Chen21-Aug-03 3:30 
GeneralRe: Question about global variables in C/C++. Pin
George221-Aug-03 15:31
George221-Aug-03 15:31 
Generalnewbie problem Pin
Anonymous20-Aug-03 15:35
Anonymous20-Aug-03 15:35 
GeneralRe: newbie problem Pin
parths20-Aug-03 15:46
parths20-Aug-03 15:46 
GeneralRe: newbie problem Pin
Anonymous20-Aug-03 15:54
Anonymous20-Aug-03 15:54 
GeneralRe: newbie problem Pin
Ted Ferenc20-Aug-03 21:42
Ted Ferenc20-Aug-03 21:42 
GeneralRe: newbie problem Pin
Dangleberry20-Aug-03 22:40
sussDangleberry20-Aug-03 22:40 
GeneralRe: newbie problem Pin
Ted Ferenc21-Aug-03 0:24
Ted Ferenc21-Aug-03 0:24 
GeneralRe: newbie problem Pin
Dangleberry21-Aug-03 0:39
sussDangleberry21-Aug-03 0:39 
GeneralRe: newbie problem Pin
Ted Ferenc21-Aug-03 1:17
Ted Ferenc21-Aug-03 1:17 
GeneralGUI qn! Pin
coda_x20-Aug-03 15:01
coda_x20-Aug-03 15:01 
GeneralRe: GUI qn! Pin
Terry O'Nolley20-Aug-03 16:16
Terry O'Nolley20-Aug-03 16:16 
GeneralRe: GUI qn! Pin
Iain Clarke, Warrior Programmer20-Aug-03 22:48
Iain Clarke, Warrior Programmer20-Aug-03 22:48 
GeneralAdd OnOK button in Cpropertysheet Pin
sdfdsfa20-Aug-03 14:50
sdfdsfa20-Aug-03 14:50 
QuestionHow can I tell... Pin
Brian Shifrin20-Aug-03 13:31
Brian Shifrin20-Aug-03 13:31 
AnswerRe: How can I tell... Pin
Garth J Lancaster20-Aug-03 17:42
professionalGarth J Lancaster20-Aug-03 17:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.