From possibly the first compilation of a project I created from scratch with the File->New->Project dialog, creating a dialog-based MFC application, I've been getting this warning:
1>c:\local\proj_vc17\diskovery\triage\resource.h(69): warning C4005: 'IDC_STATIC': macro redefinition
1>c:\program files\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\atlmfc\include\afxres.h(343): note: see previous definition of 'IDC_STATIC'
As an old-hand C/C++ guy from Unix, it's obvious what the problem is, but not why it's happening. I can't remove this because the Resource Compiler step (I can't figure out how to see the command line doing this--not visible in project->Properties->Resources->Command Line nor visible by selection project->Properties->Resources->Suppress Startup Banner=no) includes Resource.h
without including afxres.h
. So, I add a conditional compilation thusly:
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
I wasn't getting this error for several days since the last fix, but I created a new button in the dialog editor I called IDC_HELP. The resource editor then duly put that in Resource.h
, where it conflicts with a cursor ID. I renamed my buttons to IDC_HELPB but the now-unused IDC_HELP was not removed from Resource.h, necessitating a hand edit. (Note to MSFT: don't allow control IDs that conflict with MSFT-defined symbols.) OK, so I hate to do this but I don't see an alternative: I hand-edited Resource.h
to remove the IDC_HELP. For some reason it then then regenerated Resource.h
... happily without re-adding IDC_HELP, but again removing the conditional compilation of IDC_STATIC.
I'm not sure enough of the exact problem to know what my question is! Should I be asking, how to remove an unused (and conflicting) symbol from Resource.h? Or should I be asking how IDC_STATIC ever got in there in the first place?
Resource.h as it stands. Only hand-edits are the conditional compilation placed around IDC_STATIC, which MSFT put there, not me.
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Triage.rc
//
#define IDC_MYICON 2
#define IDD_FOOBAR_DIALOG 102
#define IDS_APP_TITLE 103
#define IDD_ABOUTBOX 103
#define IDM_ABOUT 104
#define IDI_FOOBAR 107
#define IDI_SMALL 108
#define IDC_FOOBAR 109
#define IDR_MAINFRAME 128
#define IDD_DIALOG1 129
#define IDD_WINFOOBAR 129
#define IDD_FOOBAR 129
#define IDR_WINFOOBAR 130
#define IDR_FOOBAR 130
#define IDI_ICON1 131
#define IDI_DIR 131
#define IDD_START 132
#define IDD_PROGRESS 133
#define IDC_ICHI 1000
#define IDC_NI 1001
#define IDC_SAN 1002
#define IDC_SHI 1003
#define IDC_GO 1004
#define IDC_ROKU 1005
#define IDC_SHOWOK 1006
#define IDC_NANA 1007
#define IDC_HACHI 1008
#define IDC_DIRL 1009
#define IDC_DIR 1010
#define IDC_UP 1011
#define IDC_EXPLORER 1012
#define IDC_PROPERTIES 1013
#define IDC_SELSUM 1014
#define IDC_DIRSUM 1015
#define IDC_BROWSE 1017
#define IDC_KU 1018
#define IDC_GREETING 1019
#define IDC_ROOTL 1020
#define IDC_ERROR 1021
#define IDC_PROGRESS 1022
#define IDC_ERRORL 1023
#define IDC_SEP 1024
#define IDC_BUTTON1 1025
#define IDC_HELPB 1027
#define ID_OPEN_ 32771
#define ID_FILE_OPENLISTS 32772
#define ID_FILE_EX 32773
#define ID_FILE_JUU 32774
#define ID_FILE_JUUICHI 32775
#define ID_VIEW_ALLSIZEDATA 32776
#define ID__UNDO 32777
#define ID__REDO 32778
#define ID_SAVELISTS 32779
#define ID_FILE_JUUNI 32780
#define ID_FILE_JUUSAN 32781
#define ID_FILE_EXIT 32782
#define ID_FILE_SAVELISTS 32783
#define ID_UNDO 32784
#define ID_REDO 32785
#define ID_OPENLISTS 32786
#define ID_JUUGO 32787
#define ID_JUUROKU 32788
#define ID_EXIT 32789
#define ID_ALLSIZEDATA 32790
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 134
#define _APS_NEXT_COMMAND_VALUE 32791
#define _APS_NEXT_CONTROL_VALUE 1029
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
Here's the preamble of my RC file. I note it's somewhat different to a freshly-created New Project-->MFC-->MFC Application-->Dialog Based, but I believe that's how I created this project as well.
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_FOOBAR ICON "Foobar.ico"
IDI_SMALL ICON "small.ico"
IDI_DIR ICON "dir.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDC_FOOBAR ACCELERATORS
BEGIN
"?", IDM_ABOUT, ASCII, ALT
"/", IDM_ABOUT, ASCII, ALT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOGEX 0, 0, 203, 63
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About Foobar"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20
LTEXT "Foobar Analyzer, v. 3.2",IDC_STATIC,42,14,154,8,SS_NOPREFIX
LTEXT "Copyright (C) 2019. All rights reserved.",IDC_STATIC,42,26,154,8
DEFPUSHBUTTON "OK",IDOK,146,42,50,14,WS_GROUP
END
(The file then describes the other dialogs of the app.)