Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Global Variables in SDI Pin
CPallini19-Apr-10 0:37
mveCPallini19-Apr-10 0:37 
GeneralRe: Global Variables in SDI Pin
LittleYellowBird19-Apr-10 0:45
LittleYellowBird19-Apr-10 0:45 
GeneralRe: Global Variables in SDI Pin
CPallini19-Apr-10 0:50
mveCPallini19-Apr-10 0:50 
GeneralRe: Global Variables in SDI Pin
hellogany19-Apr-10 0:58
hellogany19-Apr-10 0:58 
GeneralRe: Global Variables in SDI Pin
CPallini19-Apr-10 1:20
mveCPallini19-Apr-10 1:20 
GeneralRe: Global Variables in SDI Pin
hellogany19-Apr-10 17:00
hellogany19-Apr-10 17:00 
GeneralRe: Global Variables in SDI Pin
CPallini19-Apr-10 22:02
mveCPallini19-Apr-10 22:02 
GeneralRe: Global Variables in SDI Pin
Iain Clarke, Warrior Programmer19-Apr-10 23:13
Iain Clarke, Warrior Programmer19-Apr-10 23:13 
The problem here is that you have a terminology issue.

You declare the variable in HEADER file (something.h) that can be freely included in SOURCE files (*.c / *.cpp)
extern int g_MyVariable


Where you and other have an issue is that you implement the variable in another .h file, that you actually treat like a source file.
So, your compiler builds some cpp file, that is the only file including this special header.

As long as you are disciplined about this, you'll be fine.

But anyone else coming along will be puzzled.

Some day you'll make a mistake...

If you put the actual implementation
int g_MyVariable = 0;

in a source file, then you can't make this mistake.

OK, you can, but any line like:
#include "globalvars.cpp"

is going to be really obvious.

I hope that helps a little...

Iain.
I have now moved to Sweden for love (awwww).

GeneralRe: Global Variables in SDI Pin
hellogany20-Apr-10 20:22
hellogany20-Apr-10 20:22 
QuestionHow to get the hidden drives in windows? Pin
G Haranadh18-Apr-10 21:17
G Haranadh18-Apr-10 21:17 
AnswerRe: How to get the hidden drives in windows? Pin
SelvaKr18-Apr-10 23:08
SelvaKr18-Apr-10 23:08 
GeneralRe: How to get the hidden drives in windows? Pin
G Haranadh18-Apr-10 23:30
G Haranadh18-Apr-10 23:30 
AnswerRe: How to get the hidden drives in windows? Pin
Michel Godfroid19-Apr-10 0:01
Michel Godfroid19-Apr-10 0:01 
GeneralRe: How to get the hidden drives in windows? Pin
G Haranadh19-Apr-10 0:11
G Haranadh19-Apr-10 0:11 
QuestionAdding controls to an existing window Pin
depsch18-Apr-10 14:17
depsch18-Apr-10 14:17 
AnswerRe: Adding controls to an existing window Pin
Gwenio18-Apr-10 15:29
Gwenio18-Apr-10 15:29 
GeneralRe: Adding controls to an existing window Pin
depsch18-Apr-10 20:18
depsch18-Apr-10 20:18 
AnswerRe: Adding controls to an existing window Pin
Stephen Hewitt18-Apr-10 18:31
Stephen Hewitt18-Apr-10 18:31 
QuestionWindows multimedia or DirectSound - opinions wanted Pin
Vaclav_18-Apr-10 14:16
Vaclav_18-Apr-10 14:16 
AnswerRe: Windows multimedia or DirectSound - opinions wanted Pin
CPallini18-Apr-10 21:17
mveCPallini18-Apr-10 21:17 
AnswerRe: Windows multimedia or DirectSound - opinions wanted Pin
Code-o-mat18-Apr-10 21:37
Code-o-mat18-Apr-10 21:37 
QuestionCurious [Solved] Pin
Gwenio18-Apr-10 10:54
Gwenio18-Apr-10 10:54 
AnswerRe: Curious Pin
Stephen Hewitt18-Apr-10 18:28
Stephen Hewitt18-Apr-10 18:28 
GeneralRe: Curious Pin
Gwenio19-Apr-10 10:54
Gwenio19-Apr-10 10:54 
AnswerRe: Curious Pin
Richard MacCutchan19-Apr-10 1:16
mveRichard MacCutchan19-Apr-10 1:16 

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.