“在'使用'之前预期的不合格ID” [英] "expected unqualified-id before 'using'"

查看:160
本文介绍了“在'使用'之前预期的不合格ID”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很奇怪。对于以下代码片段:

#include< string>

使用std :: string;

我收到错误消息:

预期未使用的资格在使用之前

预期`,''或';''在使用之前'

没有'对我来说没有任何意义 - 预处理器指令不是以分号结束的
,我必须使用这一小块代码

数百倍。这是在我将一个笨重的大型
类切入几个较小的类之后发生的,并且在我做出更改之前,这段代码运行得很好




真的很奇怪,如果我注释掉使用声明,

编译器跳转到文件functexcept.h包含在Dev-C ++中,

并给出了与以下相同的基本错误消息

片段:

#include< exception_defines .h>


命名空间std

{...

这次它告诉我不合格的身份证位于名称空间之前。


WTF !!有人可以帮帮我吗?我不知道我可能有什么改变可能导致这种情况发生的
改变了。我有基本的C ++技能

并且我没有comp sci wiz。我只是编写基本的程序来帮助我学习或者

解析和修改文本文件。

This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
I get the error message:
expected unqualified-id before "using"
expected `,'' or `;'' before "using"
which doesn''t make any sense to me - a preprocessor directive isn''t
ended by a semicolon, and I must''ve used this little chunk of code
hundreds of times. This happened after I chopped up an unwieldy large
class into a couple of smaller classes, and this code ran just fine
before I made the changes.

The REALLY weird thing is that if I comment out the "using" statement,
the compiler jumps into the file "functexcept.h" included with Dev-C++,
and gives me the same basic error message with regards to the following
snippet:
#include <exception_defines.h>

namespace std
{ ...
This time it informs my that the "unqualified id" lies before "namespace".

WTF!! Can anybody help me out here? I have no idea what I might have
changed that could possibly have caused this. I have basic C++ skills
and am no comp sci wiz. I just write basic progs to help me study or
parse and modify text files.

推荐答案

" Squid Seven" < TE ********* @ squidseven.com>在消息中写道

新闻:mJ ******************** @ adelphia.com ...
"Squid Seven" <te*********@squidseven.com> wrote in message
news:mJ********************@adelphia.com...
这个真奇怪。对于以下代码片段:

#include< string>
使用std :: string;

我收到错误消息:

预期不合格的id在使用之前
期望`,''或';''在使用之前
This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
I get the error message:
expected unqualified-id before "using"
expected `,'' or `;'' before "using"




可能是标题文件字符串已损坏,可能在最后...


使用编译器的选项获取预处理器输出以查看

编译器是什么实际上看到了。


Ali



Probably the header file string is corrupted, likely at the end...

Use your compiler''s options to get the preprocessor output to see what the
compiler is actually seeing.

Ali




" Squid Seven" < TE ********* @ squidseven.com>在消息中写道

新闻:mJ ******************** @ adelphia.com ...

"Squid Seven" <te*********@squidseven.com> wrote in message
news:mJ********************@adelphia.com...
这个真奇怪。对于以下代码片段:

#include< string>
使用std :: string;

我收到错误消息:

预期不合格的id在使用
期望的',''或';''之前使用

对我没有任何意义 - 一个预处理器指令并没有以分号结束,我必须使用这几小块代码数百次。这发生在我将一个笨重的大班级切成几个小班级之后,这段代码在我进行
更改之前运行得很好。

真正奇怪的是如果我注释掉使用语句,
编译器跳转到文件functexcept.h包含在Dev-C ++中,并且
给出了与以下
片段相同的基本错误消息:

#include< exception_defines.h>

namespace std
{...

这次它告诉我不合格的身份证位于命名空间之前。

WTF !!有人可以帮帮我吗?我不知道我可能有什么改变可能导致这种情况。我有基本的C ++技能,而且没有comp sci wiz。我只是编写基本的程序来帮助我学习或解析
并修改文本文件。
This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
I get the error message:
expected unqualified-id before "using"
expected `,'' or `;'' before "using"
which doesn''t make any sense to me - a preprocessor directive isn''t ended
by a semicolon, and I must''ve used this little chunk of code hundreds of
times. This happened after I chopped up an unwieldy large class into a
couple of smaller classes, and this code ran just fine before I made the
changes.

The REALLY weird thing is that if I comment out the "using" statement, the
compiler jumps into the file "functexcept.h" included with Dev-C++, and
gives me the same basic error message with regards to the following
snippet:
#include <exception_defines.h>

namespace std
{ ...
This time it informs my that the "unqualified id" lies before "namespace".

WTF!! Can anybody help me out here? I have no idea what I might have
changed that could possibly have caused this. I have basic C++ skills and
am no comp sci wiz. I just write basic progs to help me study or parse
and modify text files.




一些想法/可能性。猜猜,真的。


一个是你有一个头文件或源文件中的一行之前

这个行结尾不正确。例如,如果您在Windows和Mac之间运输了一个文件,那么您的林德结尾会被搞砸,并导致像这样的奇怪行为。如果它是你从某个地方复制并粘贴的行,请尝试删除一些代码并手动重新输入。


另一个想法是因为你改变了源文件或路径,以前的编译会以某种方式搞乱你,或许是因为
。尝试完整,干净的重建。


如果头文件的结尾是

行注释,我在某些编译器上也遇到了问题(使用//),或者是一个没有尾随

分号的类定义。检查标题的末尾,看看它们是否正常。


哦,并检查你的编译器/构建设置和路径,以确保你没有

选择了一些你不想要的目标/库/框架。


-Howard



A few ideas/possibilities. Guesses, really.

One is that you''ve got a header file or a line in that source file before
this with incorrect line endings. If you''ve transported a file between
Windows and Mac, for instance, your linde endings get screwed up, and cause
weird behavior like this. If it''s a line you copied and pasted from
somewhere, try deleting some of the code and re-typing it in by hand.

Another idea is that a previous compile is somehow messing with you, perhaps
because you changed source files or paths. Try a complete, clean rebuild.

I''ve also seen problems on some compilers if the end of a header file is a
line-comment (using //), or is a class definition without a trailing
semicolon. Check the ends of your headers and see if they''re ok.

Oh, and check your compiler/build settings and paths, to be sure you haven''t
selected some target/library/framework you didn''t intend.

-Howard





Howard写道:


Howard wrote:
" Squid Seven" < TE ********* @ squidseven.com>在消息中写道
新闻:mJ ******************** @ adelphia.com ......
"Squid Seven" <te*********@squidseven.com> wrote in message
news:mJ********************@adelphia.com...
这个真奇怪。对于以下代码片段:

#include< string>
使用std :: string;

我收到错误消息:

预期不合格的id在使用
期望的',''或';''之前使用

对我没有任何意义 - 一个预处理器指令并没有以分号结束,我必须使用这几小块代码数百次。这发生在我将一个笨重的大班级切成几个小班级之后,这段代码在我进行
更改之前运行得很好。

真正奇怪的是如果我注释掉使用语句,
编译器跳转到文件functexcept.h包含在Dev-C ++中,并且
给出了与以下
片段相同的基本错误消息:

#include< exception_defines.h>

namespace std
{...

这次它告诉我不合格的身份证位于命名空间之前。

WTF !!有人可以帮帮我吗?我不知道我可能有什么改变可能导致这种情况。我有基本的C ++技能,而且没有comp sci wiz。我只是编写基本的程序来帮助我学习或解析
并修改文本文件。

一些想法/可能性。猜猜,真的。

一个是你的源文件中有一个头文件或一行,然而这个行结尾不正确。例如,如果你在Windows和Mac之间传输了一个文件,你的林德结尾就会被搞砸,并导致像这样的怪异行为。如果它是你在某处复制并粘贴的行,请尝试删除一些代码并手动重新输入。
This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
I get the error message:
expected unqualified-id before "using"
expected `,'' or `;'' before "using"
which doesn''t make any sense to me - a preprocessor directive isn''t ended
by a semicolon, and I must''ve used this little chunk of code hundreds of
times. This happened after I chopped up an unwieldy large class into a
couple of smaller classes, and this code ran just fine before I made the
changes.

The REALLY weird thing is that if I comment out the "using" statement, the
compiler jumps into the file "functexcept.h" included with Dev-C++, and
gives me the same basic error message with regards to the following
snippet:
#include <exception_defines.h>

namespace std
{ ...
This time it informs my that the "unqualified id" lies before "namespace".

WTF!! Can anybody help me out here? I have no idea what I might have
changed that could possibly have caused this. I have basic C++ skills and
am no comp sci wiz. I just write basic progs to help me study or parse
and modify text files.

A few ideas/possibilities. Guesses, really.

One is that you''ve got a header file or a line in that source file before
this with incorrect line endings. If you''ve transported a file between
Windows and Mac, for instance, your linde endings get screwed up, and cause
weird behavior like this. If it''s a line you copied and pasted from
somewhere, try deleting some of the code and re-typing it in by hand.




阿里说它也可能是一个损坏的头文件。他建议我使用

我的编译器设置来获得我的预处理器输出。我已经花了过去半小时的时间来试图弄清楚如何做到这一点。头文件

如何被破坏?我没有传输或移动文件或以任何方式

与他们交互,除非间接通过修改我的OWN文件在

Dev-C ++中。 Urgh。我很糟糕!

另一个想法是,之前的编译在某种程度上会弄乱你,也许是因为你改变了源文件或路径。尝试一个完整,干净的重建。


尝试完全重建,没有运气

如果标题末尾我也看到了一些编译器的问题file是一个
行注释(使用//),或者是一个没有尾随分号的类定义。检查标题的末尾,看看它们是否正常。

哦,检查你的编译器/构建设置和路径,确保你没有选择一些目标/ library / framework你并不打算。

-Howard



Ali said that it might be a corrupted header file too. He suggest I use
my compiler settings to get my preprocessor output. I''ve spent the past
half-hour trying to figure out how to do that. How does a header file
get corrupted? I didn''t transfer or move the files or in any way
interact with them except indirectly by modifying my OWN files in
Dev-C++. Urgh. I am SO FRUSTRATED!
Another idea is that a previous compile is somehow messing with you, perhaps
because you changed source files or paths. Try a complete, clean rebuild.

tried the complete rebuild, no luck
I''ve also seen problems on some compilers if the end of a header file is a
line-comment (using //), or is a class definition without a trailing
semicolon. Check the ends of your headers and see if they''re ok.

Oh, and check your compiler/build settings and paths, to be sure you haven''t
selected some target/library/framework you didn''t intend.

-Howard



这篇关于“在'使用'之前预期的不合格ID”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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