All right so I created a C++ Win32 program that worked fine. Then I wanted to use a custom icon so I created a "resource.h" file and a "resource.rc" file and I #include
'd them both in my C++ source file. However on compilation I get the following error for line 3:
expected unqualified-id before numeric constant
What am I doing wrong? Am I forgetting something?
My resource.h file:
#define IDI_MYICON 201
My resource.rc file:
#include "resource.h"
IDI_MYICON ICON "star.ico"
Finally the first three line (the ones with the problem) of my C++ Win32 file:
#include <windows.h>
#include "resource.h"
#include "resource.rc"
You are not supposed to include the .rc file into your source code, just the .h file. You are supposed to compile the .rc file separately into a .res file using your development environment's resource compiler, and then link the .res file into the final executable.
You don't include .RC
files into C++ files. You compile them with RC.EXE
(the resource compiler). This generates a .RES
file that you give to the linker along with your other .OBJ
files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.