[Turn] #error No Target Architecture that is easy to appear in C++

Project environment: win 7 64-bit, compilation environment: VS2013

Recently, I was writing a C++ project and found a lot of things I didn't know. This also made my growth in C++ faster. Now I will talk about some problems I encountered while writing the project. I hope you can help me. to some people.

The first thing to mention is:

#error "No Target Architecture"
Since I showed it with highlighting, it means that this error is relatively easy for everyone to encounter, because this error took a long time, so I have to tell you, first of all, it is not our own header file but the VS system. The header file, which is confusing, so it is certain that there is something wrong with our program. Where to start investigating? I will tell you about my method. Generally, I encounter an error in the header file of the system:
1. First look at the compilation environment of the VS compiler, whether it is in Debug mode, and whether the configuration environment is X64 (because mine is 64-bit, this varies depending on the system environment)
2. Then check whether the runtime library in the code generation of the project property page is multi-threaded debugging MDd, which is more important
3. The compiler and system are all checked in the front. Now we start to check the code. First, put the error on Baidu or Google to see if there is any experience in solving the problem. If not, Google learned that this is because we included header files that should not be included. What we need to do at this time is to try to replace all system header files with <windows.h>.
Because the header file <windows.h> contains most of the system files, but other header files may not be included at the same time. At this time, we need to use <windows.h> to try to replace, if replace If no error is reported, it means that the header file you replaced does exist in <windows.h>. If an error occurs, continue to include the original header file. If correct, this problem can be solved.
4. Especially the header files such as <windef.h><winuser.h>, after the replacement, the problem can be solved and everything will be fine, but if it is not solved, the next step is to change the order of the header files, for example, at the beginning
#include <a.h>
#include <b.h>
This time replace it with
#include <b.h>
#include <a.h>
Maybe that will solve the problem.
5. Finally, give a little advice. Don’t be afraid when you encounter problems. You need to analyze step by step, so that you may become more and more courageous. If you encounter many problems and solve them, you will not have so much fear. The most important thing is Do you want to solve this problem on your own?
 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325086137&siteId=291194637