1. Introduction

When you use the Microsoft Visual Studio to compile a cpp project, and encounter this problem about error RC2104: undefined keyword: Key, here is an article on how to fix this problem.

2. Review

The picture best illustrates the problem, the error message and related code is shown as below image:

image

Therefore, let’s find more about the error RC2104. And the error definition can be found in Resource Compiler Error RC2104.

This error is often caused by a typo in the resource definition, or in the included header file. It can also be caused by a missing header file.

image

But here the problem is quite strange, when you locate to the error code, you will find that there is no syntax error at all. But why it always shows us the error on this string?

image

Therefore, let us continue to look for possible errors in the resource file. A place that is most likely to cause this problem comes into view.

image

We see here that the code page of the resource will be set to 936, but our current resource file is UTF-8 encoded, here is very likely to cause the resource compiler to use the wrong code page to read the content, and eventually cause this error.

So let us comment this line of code page setting:

image

and recompile the project again:

image

Wow! What an exciting moment, isn’t it?

3. Conclusion

Now we know that this error is caused by the code page setting does not match the actual file character encoding, so we need to pay special attention to this problem, especially when you are compiling a project written on different language of operating system.