C
Chuckie72
Guest
Hello
I have a header file which has these global constants:
const TCHAR kDateKeyXML[] = { _T("W%Y%m%d") };
const char kMWB[] = { "MeetingWorkBook" };
const char kSongOpen[] = { "SongOpen" };
const char kSongMiddle[] = { "SongMiddle" };
const char kSongEnd[] = { "SongEnd" };
const char kFirstWeek[] = { "FirstWeekOfMonth" };
const char kBibleReading[] = { "WeeklyBibleReading" };
const char kCBSMaterial[] = { "CongregationBibleStudySourceMaterial" };
const char kTFGW[] = { "TreasuresFromGodsWord" };
const char kLAC[] = { "LivingAsChristians" };
const char kItem[] = { "Item" };
const char kTheme[] = { "Theme" };
const char kMethod[] = { "Method" };
const char kTime[] = { "Time" };
const char kItemCount[] = { "ItemCount" };
I decided to change the declaration to this:
LPCTSTR kDateKeyXML = { _T("W%Y%m%d") };
LPCSTR kMWB = { "MeetingWorkBook" };
LPCSTR kSongOpen = { "SongOpen" };
LPCSTR kSongMiddle = { "SongMiddle" };
LPCSTR kSongEnd = { "SongEnd" };
LPCSTR kFirstWeek = { "FirstWeekOfMonth" };
LPCSTR kBibleReading = { "WeeklyBibleReading" };
LPCSTR kCBSMaterial = { "CongregationBibleStudySourceMaterial" };
LPCSTR kTFGW = { "TreasuresFromGodsWord" };
LPCSTR kLAC = { "LivingAsChristians" };
LPCSTR kItem = { "Item" };
LPCSTR kTheme = { "Theme" };
LPCSTR kMethod = { "Method" };
LPCSTR kTime = { "Time" };
LPCSTR kItemCount = { "ItemCount" };
But that was a big mistake. When I did a full recompile of my application in VS2015 I got these errors:
4>ChristianLifeMinistryEntry.obj : error LNK2005: "wchar_t const * const kDateKeyXML" (?kDateKeyXML@@3PEB_WEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kMWB" (?kMWB@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kSongOpen" (?kSongOpen@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kSongMiddle" (?kSongMiddle@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kSongEnd" (?kSongEnd@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kFirstWeek" (?kFirstWeek@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kBibleReading" (?kBibleReading@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kCBSMaterial" (?kCBSMaterial@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kTFGW" (?kTFGW@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kLAC" (?kLAC@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kItem" (?kItem@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kTheme" (?kTheme@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kMethod" (?kMethod@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kTime" (?kTime@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kItemCount" (?kItemCount@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "wchar_t const * const kDateKeyXML" (?kDateKeyXML@@3PEB_WEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kMWB" (?kMWB@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kSongOpen" (?kSongOpen@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kSongMiddle" (?kSongMiddle@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kSongEnd" (?kSongEnd@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kFirstWeek" (?kFirstWeek@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kBibleReading" (?kBibleReading@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kCBSMaterial" (?kCBSMaterial@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kTFGW" (?kTFGW@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kLAC" (?kLAC@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kItem" (?kItem@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kTheme" (?kTheme@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kMethod" (?kMethod@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kTime" (?kTime@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kItemCount" (?kItemCount@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
Why? I have tried to read up on the error but I don't understand why changing the way I did caused the link issues. I ended up reverting to the former method and it compiles again.
Thanks for any explanation.
Andrew
Continue reading...
I have a header file which has these global constants:
const TCHAR kDateKeyXML[] = { _T("W%Y%m%d") };
const char kMWB[] = { "MeetingWorkBook" };
const char kSongOpen[] = { "SongOpen" };
const char kSongMiddle[] = { "SongMiddle" };
const char kSongEnd[] = { "SongEnd" };
const char kFirstWeek[] = { "FirstWeekOfMonth" };
const char kBibleReading[] = { "WeeklyBibleReading" };
const char kCBSMaterial[] = { "CongregationBibleStudySourceMaterial" };
const char kTFGW[] = { "TreasuresFromGodsWord" };
const char kLAC[] = { "LivingAsChristians" };
const char kItem[] = { "Item" };
const char kTheme[] = { "Theme" };
const char kMethod[] = { "Method" };
const char kTime[] = { "Time" };
const char kItemCount[] = { "ItemCount" };
I decided to change the declaration to this:
LPCTSTR kDateKeyXML = { _T("W%Y%m%d") };
LPCSTR kMWB = { "MeetingWorkBook" };
LPCSTR kSongOpen = { "SongOpen" };
LPCSTR kSongMiddle = { "SongMiddle" };
LPCSTR kSongEnd = { "SongEnd" };
LPCSTR kFirstWeek = { "FirstWeekOfMonth" };
LPCSTR kBibleReading = { "WeeklyBibleReading" };
LPCSTR kCBSMaterial = { "CongregationBibleStudySourceMaterial" };
LPCSTR kTFGW = { "TreasuresFromGodsWord" };
LPCSTR kLAC = { "LivingAsChristians" };
LPCSTR kItem = { "Item" };
LPCSTR kTheme = { "Theme" };
LPCSTR kMethod = { "Method" };
LPCSTR kTime = { "Time" };
LPCSTR kItemCount = { "ItemCount" };
But that was a big mistake. When I did a full recompile of my application in VS2015 I got these errors:
4>ChristianLifeMinistryEntry.obj : error LNK2005: "wchar_t const * const kDateKeyXML" (?kDateKeyXML@@3PEB_WEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kMWB" (?kMWB@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kSongOpen" (?kSongOpen@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kSongMiddle" (?kSongMiddle@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kSongEnd" (?kSongEnd@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kFirstWeek" (?kFirstWeek@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kBibleReading" (?kBibleReading@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kCBSMaterial" (?kCBSMaterial@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kTFGW" (?kTFGW@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kLAC" (?kLAC@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kItem" (?kItem@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kTheme" (?kTheme@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kMethod" (?kMethod@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kTime" (?kTime@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>ChristianLifeMinistryEntry.obj : error LNK2005: "char const * const kItemCount" (?kItemCount@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "wchar_t const * const kDateKeyXML" (?kDateKeyXML@@3PEB_WEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kMWB" (?kMWB@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kSongOpen" (?kSongOpen@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kSongMiddle" (?kSongMiddle@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kSongEnd" (?kSongEnd@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kFirstWeek" (?kFirstWeek@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kBibleReading" (?kBibleReading@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kCBSMaterial" (?kCBSMaterial@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kTFGW" (?kTFGW@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kLAC" (?kLAC@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kItem" (?kItem@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kTheme" (?kTheme@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kMethod" (?kMethod@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kTime" (?kTime@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
4>SoundRotaDlg.obj : error LNK2005: "char const * const kItemCount" (?kItemCount@@3PEBDEB) already defined in ChristianLifeMinistryEditorDlg.obj
Why? I have tried to read up on the error but I don't understand why changing the way I did caused the link issues. I ended up reverting to the former method and it compiles again.
Thanks for any explanation.
Andrew
Continue reading...