Click here to Skip to main content
14,765,367 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C++ - Accessibility of object after deletion. (illegal still working), why this is happening? Pin
Jochen Arndt4-Dec-15 2:45
professionalJochen Arndt4-Dec-15 2:45 
GeneralRe: C++ - Accessibility of object after deletion. (illegal still working), why this is happening? Pin
CPallini4-Dec-15 10:18
mveCPallini4-Dec-15 10:18 
QuestionFloating point conversion Pin
Still learning how to code3-Dec-15 23:19
MemberStill learning how to code3-Dec-15 23:19 
AnswerRe: Floating point conversion Pin
Michael_Davies3-Dec-15 23:29
MemberMichael_Davies3-Dec-15 23:29 
GeneralRe: Floating point conversion Pin
Richard MacCutchan3-Dec-15 23:40
mveRichard MacCutchan3-Dec-15 23:40 
GeneralRe: Floating point conversion Pin
Michael_Davies4-Dec-15 22:08
MemberMichael_Davies4-Dec-15 22:08 
GeneralRe: Floating point conversion Pin
Richard MacCutchan4-Dec-15 23:12
mveRichard MacCutchan4-Dec-15 23:12 
AnswerRe: Floating point conversion Pin
Richard MacCutchan3-Dec-15 23:39
mveRichard MacCutchan3-Dec-15 23:39 
AnswerRe: Floating point conversion Pin
Jochen Arndt4-Dec-15 0:10
professionalJochen Arndt4-Dec-15 0:10 
GeneralRe: Floating point conversion Pin
Still learning how to code5-Dec-15 1:29
MemberStill learning how to code5-Dec-15 1:29 
AnswerRe: Floating point conversion Pin
CPallini4-Dec-15 0:30
mveCPallini4-Dec-15 0:30 
GeneralRe: Floating point conversion Pin
k50544-Dec-15 5:21
mvek50544-Dec-15 5:21 
QuestionIEEE 754-1985 Pin
enhzflep4-Dec-15 6:43
Memberenhzflep4-Dec-15 6:43 
AnswerRe: Floating point conversion Pin
S.T.K8-Dec-15 4:19
MemberS.T.K8-Dec-15 4:19 
QuestionComboboxx issue in MFC Pin
Amrit Agr3-Dec-15 3:48
MemberAmrit Agr3-Dec-15 3:48 
SuggestionRe: Comboboxx issue in MFC Pin
Richard MacCutchan3-Dec-15 4:50
mveRichard MacCutchan3-Dec-15 4:50 
QuestionVisual Studio error LNK2005: variable XXX redefined in xxx.obj Pin
Javier Luis Lopez26-Nov-15 1:09
MemberJavier Luis Lopez26-Nov-15 1:09 
AnswerRe: Visual Studio errYou should declare it or LNK2005: variable XXX redefined in xxx.obj Pin
Richard MacCutchan26-Nov-15 1:24
mveRichard MacCutchan26-Nov-15 1:24 
GeneralRe: Visual Studio errYou should declare it or LNK2005: variable XXX redefined in xxx.obj Pin
Javier Luis Lopez26-Nov-15 1:53
MemberJavier Luis Lopez26-Nov-15 1:53 
GeneralRe: Visual Studio errYou should declare it or LNK2005: variable XXX redefined in xxx.obj Pin
Richard MacCutchan26-Nov-15 2:11
mveRichard MacCutchan26-Nov-15 2:11 
GeneralRe: Visual Studio errYou should declare it or LNK2005: variable XXX redefined in xxx.obj Pin
Javier Luis Lopez26-Nov-15 4:29
MemberJavier Luis Lopez26-Nov-15 4:29 
GeneralRe: Visual Studio errYou should declare it or LNK2005: variable XXX redefined in xxx.obj Pin
Richard MacCutchan26-Nov-15 5:26
mveRichard MacCutchan26-Nov-15 5:26 
AnswerRe: Visual Studio error LNK2005: variable XXX redefined in xxx.obj Pin
Daniel Pfeffer26-Nov-15 7:34
professionalDaniel Pfeffer26-Nov-15 7:34 
Another way to solve this problem (and have only one place where the variable is defined):

In foo.h:
#ifdef DEFINE_GLOBALS
#define GLOBAL
#define INIT(x) = (x)
#else
#define GLOBAL extern
#define INIT(x)
#endif

GLOBAL int globalInt INIT(42);


In foo.cpp (and ONLY in foo.cpp):
#define DEFINE_GLOBALS
#include "foo.h"


In other source files:
#include "foo.h"

If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.

--Winston Churchill

GeneralRe: Visual Studio error LNK2005: variable XXX redefined in xxx.obj Pin
CPallini26-Nov-15 22:09
mveCPallini26-Nov-15 22:09 
GeneralRe: Visual Studio error LNK2005: variable XXX redefined in xxx.obj Pin
Richard MacCutchan26-Nov-15 23:23
mveRichard MacCutchan26-Nov-15 23:23 

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.