typedef / struct和范围问题 [英] typedef /struct and the scope problems

查看:79
本文介绍了typedef / struct和范围问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个头文件:


struct AAAA

{

blabla .....

};

typedef struct AAAA A;

typedef struct BBB

{

blabla ...

.....

} B;

我尝试编译它并收到AAA的错误消息已经在当前范围内声明了
! (我检查到处都是

不是!)

有趣的是,当我删除第二个typedef时它会编译

好吧。

任何想法为什么会出现这种奇怪的行为?

谢谢?

lets say I have a header file :

struct AAAA
{
blabla.....
};
typedef struct AAAA A;
typedef struct BBB
{
blabla...
.....
} B;
I try to compile it and get an error message that "AAA" has already
been declared in the current scope ! ( And I checked everywhere it is
not ! )
What''s funny is , that when I remove the second typedef it compiles
well.
Any ideas why such a weird behavior ?
Thanks ?

推荐答案

在2006-03-03,我的********** @ gmail.com < my ********** @ gmail.com>写道:
On 2006-03-03, my**********@gmail.com <my**********@gmail.com> wrote:
让我说我有一个头文件:

struct AAAA
{
blabla .....
};
typedef struct AAAA A;

typedef struct BBB
{bla / / ...
.....
} B;

我尝试编译它并得到一条错误消息AAA已经在当前范围内宣布了! (我检查它到处都没有!)
有趣的是,当我删除第二个typedef时,它很好地编译

任何想法为何如此奇怪行为?
谢谢?
lets say I have a header file :

struct AAAA
{
blabla.....
};
typedef struct AAAA A;
typedef struct BBB
{
blabla...
.....
} B;
I try to compile it and get an error message that "AAA" has already
been declared in the current scope ! ( And I checked everywhere it is
not ! )
What''s funny is , that when I remove the second typedef it compiles
well.
Any ideas why such a weird behavior ?
Thanks ?




不知道。您正在使用什么编译器,它可能会被破坏



No idea. What compiler are you using, it may be broken


" my ********** @ gmail.com" <我的********** @ gmail.com>写道:
"my**********@gmail.com" <my**********@gmail.com> writes:
让我说我有一个头文件:

struct AAAA
{
blabla .....
};
typedef struct AAAA A;

typedef struct BBB
{bla / / ...
.....
} B;

我尝试编译它并得到一条错误消息AAA已经在当前范围内宣布了! (我检查它到处都没有!)
有趣的是,当我删除第二个typedef时,它很好地编译

任何想法为何如此奇怪行为?
lets say I have a header file :

struct AAAA
{
blabla.....
};
typedef struct AAAA A;
typedef struct BBB
{
blabla...
.....
} B;
I try to compile it and get an error message that "AAA" has already
been declared in the current scope ! ( And I checked everywhere it is
not ! )
What''s funny is , that when I remove the second typedef it compiles
well.
Any ideas why such a weird behavior ?




这很奇怪,我在blabla .....上得到一个解析错误。


如果我修复了语法错误,它会编译而不会出错。显然

错误是在代码中你没有打扰给我们看的(可能在线

42)。


如果您发布一个完整的可编辑源文件,该文件显示

问题,我们可能会提供帮助。如果没有,我们不是思想家。


-

Keith Thompson(The_Other_Keith) ks *** @ mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。



That''s odd, I get a parse error on "blabla.....".

If I fix the syntax errors, it compiles without error. Obviously the
error is in code you haven''t bothered to show us (probably on line
42).

If you post a complete compilable source file that exhibits the
problem, we can probably help. If not, we''re not mindreaders.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


英特尔的。

Intel''s one.


这篇关于typedef / struct和范围问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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