Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if there is an undefined identifier error in C++?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to do undefined identifier errors in c++. It has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.

vscode When writing c, variables defined between #ifdef#endif can jump to the definition when referring, but will prompt "undefined identifier" error.

C++ always shows undefined identifier error?

source code

#include"stdafx.h"

#include"vpn.h"

#include"vpnDlg.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#endif

//CvpnApp

intBEGIN_MESSAGE_MAP(CvpnApp,CWinApp)

ON_COMMAND(ID_HELP,&CWinApp::OnHelp)

END_MESSAGE_MAP()

//CvpnApp construction

CvpnApp::CvpnApp()

{

//Support Restart Manager

m_dwRestartManagerSupportFlags=AFX_RESTART_MANAGER_SUPPORT_RESTART;

//TODO: Add construction code here,

C++ What about undefined identifier errors?

1. Usually when defining a variable of a certain type, we need to introduce the corresponding header file, so that the system can distinguish the identifier.

2. In the warning bar, it is found that the header file information is not recognized, but is skipped by the system when looking for precompiled headers, because it is normal if the relevant.h file is not introduced in.cpp, but now the relevant header file has been introduced, but errorC2065, errorC3861, errorC2228... mistakes.

3. That is to say, the header file does not take effect here, but is directly skipped, and naturally its corresponding identifier will not be recognized. Then I moved the #include"stdafx.h" header file to the top and tried to debug it. The result was no longer an undeclared identifier error, and the compilation was successful.

4. There is also an error prompt here. When we encounter an external symbol that cannot be resolved, we have to check that the files we refer to may not be complete. Here, I just did not introduce the file "Fwleb32.lib" into the project, which led to the error.

Thank you for reading this article carefully. I hope the article "What to do if there is an undefined identifier error in c++" shared by Xiaobian is helpful to everyone. At the same time, I hope you will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report