错误1错误C2146:语法错误:缺少'; '在标识符之前'cfg' [英] Error 1 error C2146: syntax error : missing '; ' before identifier 'cfg'

查看:143
本文介绍了错误1错误C2146:语法错误:缺少'; '在标识符之前'cfg'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



这是一个C ++ / CLR项目。

我的头文件中有以下结构:

Hello All,

It's an C++/CLR project.
I have below structure in my header file:

value struct CONFIG
{	
	System::String^ Exch_Feeds;
	System::String^ Exch_Type;
	System::String^ Feeds_Type;
	int Feeds_port;
	int Max_Users;

	int IML_port;

	System::String^ Interface_IP;

	System::String^ Nse_Mcast_Host;
	int Nse_Mcast_Port;
	System::String^ Fno_Mcast_Host;
	int Fno_Mcast_Port;
	System::String^ Curr_Mcast_Host;
	int Curr_Mcast_Port;

	System::String^ Nse_Tcp_Host;
	int Nse_Tcp_Port;
	System::String^ Fno_Tcp_Host;
	int Fno_Tcp_Port;

	System::String^ Mcast_Host;
	int Mcast_Port;
	int Log_file;
	int Row_feed_file;

	System::String^ DownloadHost;

	short exchange_ctr;

	System::String^ dbserver;	
	System::String^ dbuser;
	System::String^ dbpass;
	System::String^ dbdb;
	int dbport;
};





并在我的.cpp文件中使用它作为CONFIG cfg;



但它给了我以下错误:





And using it in my .cpp file as CONFIG cfg;

But it's giving me below errors:

Error	1	error C2146: syntax error : missing ';' before identifier 'cfg'		9	1
Error	2	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int		9	1
Error	3	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int		9	1





有人可以查看并解释为什么会出现这些错误。



这是一个C ++ / CLR项目。



我的尝试:



通过将我的结构作为一个类来尝试使用它,但仍然是同样的错误。



Can some one have look and explain why am getting these errors.

It's an C++/CLR project.

What I have tried:

Tried using it by making my structure as a class, but still same error.

推荐答案

你的问题确实存在似乎不在结构声明中,而是在你尝试使用它的地方。

你展示的代码不包含任何 cfg 标识符。在代码中找到此标识符,您很可能忘记使用分号终止其中一个语句。
Your problem does not seem to be in the structure declaration, but rather where you try to use it.
The code you showed does not hold any cfg identifier. Find this identifier in your code, you most likely forgot to terminate one of your statements with a semicolon.


这篇关于错误1错误C2146:语法错误:缺少'; '在标识符之前'cfg'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆