Click here to Skip to main content
15,913,096 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalblocking processes Pin
kanetheterrible114-May-04 18:39
kanetheterrible114-May-04 18:39 
GeneralConstrol bar and splitters Pin
alex.barylski14-May-04 18:37
alex.barylski14-May-04 18:37 
GeneralAssigning a value to a static char array Pin
monrobot1314-May-04 17:50
monrobot1314-May-04 17:50 
GeneralRe: Assigning a value to a static char array Pin
nguyenvhn14-May-04 18:00
nguyenvhn14-May-04 18:00 
GeneralRe: Assigning a value to a static char array Pin
Michael Dunn14-May-04 20:13
sitebuilderMichael Dunn14-May-04 20:13 
QuestionAccessing distant database from a program? Pin
__Cerb14-May-04 15:42
__Cerb14-May-04 15:42 
AnswerRe: Accessing distant database from a program? Pin
nguyenvhn14-May-04 18:04
nguyenvhn14-May-04 18:04 
General#include nightmare Pin
Ernesto D.14-May-04 13:39
Ernesto D.14-May-04 13:39 
Hi all, whenever i need some symbols/constants to be avairable to my entire application (all its files i mean), i create a header file (appconsts.h), and i #include it in each .cpp file of my application. this always worked fine, till recently, i recived some advice to stop using macros (#define) to define constants, and started using const, so (in my current project) i happily went to my appconsts.h file, and changed it like this (an example):

Before:
#if !defined(APPCONSTS_H)
#define APPCONSTS_H

#define MY_STRING _T("a string")
#define MY_NUMBER 100
enum MY_ENUM{En1=0, En2, En3};

#endif

AFTER:

#if !defined(APPCONSTS_H)
#define APPCONSTS_H

const TCHAR* MY_STRING = _T("a string");
const int MY_NUMBER = 100;
enum MY_ENUM{En1=0, En2, En3};

#endif

its all very nice, the only problem is that i now get 708 errors (yes 708), about MY_STRING and MY_NUMBER allready being defined in another object. for example:
ClientEditDlg.obj : error LNK2005: "char const * const COLHT_VLV_NOTES" (?COLHT_VLV_NOTES@@3PBDB) already defined in Boletaje.obj

onfigSheet.obj : error LNK2005: "char const * const IF_FILENAME" (?IF_FILENAME@@3PBDB) already defined in Boletaje.obj

please notice that i DID include guards on the appconsts.h file, i tried removing all the #includes to appconsts.h file, and just including it in my stdafx.h file, but no luck, and since this is a WTL project, i dont have any other file (besides stdafx.h) that gets included everywhere.
Can someone help me out?

***UPDATE***
mhh, i get it now, i should declare the consts in some .cpp file (say where my winmain()is), and then op appconsts.h i should do like this:

extern const TCHAR* MY_STRING = _T("a string");
extern const int MY_NUMBER = 100;
enum MY_ENUM{En1=0, En2, En3};

is this correct?
if so, wouldnt be easyer to just use #define instead of const? i mean, MS uses it! for example in winuser.h:
// ShowWindow() Commands
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
...

what you guys think?

GeneralRe: #include nightmare Pin
Michael Dunn14-May-04 13:44
sitebuilderMichael Dunn14-May-04 13:44 
GeneralRe: #include nightmare Pin
Ernesto D.14-May-04 13:50
Ernesto D.14-May-04 13:50 
GeneralRe: #include nightmare Pin
Michael Dunn14-May-04 14:04
sitebuilderMichael Dunn14-May-04 14:04 
GeneralRe: #include nightmare Pin
Ernesto D.14-May-04 15:23
Ernesto D.14-May-04 15:23 
Generali need help with CopyFile Pin
Ryan McDermott14-May-04 12:50
Ryan McDermott14-May-04 12:50 
GeneralRe: i need help with CopyFile Pin
Anonymous14-May-04 13:46
Anonymous14-May-04 13:46 
QuestionHow to response WM_LBUTTONDBLCLK in the MDIClient area? Pin
huyoo14-May-04 11:56
huyoo14-May-04 11:56 
AnswerRe: How to response WM_LBUTTONDBLCLK in the MDIClient area? Pin
huyoo15-May-04 6:49
huyoo15-May-04 6:49 
GeneralConsole runtime null variables Pin
Cpudood14-May-04 11:53
Cpudood14-May-04 11:53 
GeneralRe: Console runtime null variables Pin
Maarten Kools14-May-04 12:00
professionalMaarten Kools14-May-04 12:00 
QuestionNeed to retrieve data from a dialog into my class(not MFC class) How? Pin
Larry A Mills14-May-04 11:53
Larry A Mills14-May-04 11:53 
GeneralCasting into a short from a byte array Pin
Wheatbread14-May-04 11:45
Wheatbread14-May-04 11:45 
GeneralRe: Casting into a short from a byte array Pin
Wheatbread14-May-04 11:58
Wheatbread14-May-04 11:58 
QuestionHow to get HWND of VC++ OCX from VB Client Pin
Nirav Doshi14-May-04 11:23
Nirav Doshi14-May-04 11:23 
AnswerRe: How to get HWND of VC++ OCX from VB Client Pin
Member 42102514-May-04 14:27
Member 42102514-May-04 14:27 
GeneralRe: How to get HWND of VC++ OCX from VB Client Pin
Nirav Doshi14-May-04 21:37
Nirav Doshi14-May-04 21:37 
GeneralHelp for a New programmer Pin
Anonymous14-May-04 9:42
Anonymous14-May-04 9: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.