无法typedef结构 [英] Can't typedef a struct

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

问题描述

我在一个.h文件中有这个,我把它包含在.cpp文件中:


typedef struct {

double x;

双倍;

} pointz;


但是当我编译时我得到:


图形/debug.h:13:错误:冲突声明?typedef struct

pointz pointz?

graphics / debug.h:13:error:?pointz?有一个先前的声明为

?typedef struct pointz pointz?


但我之前没有声明''积分''。

I have this in a .h file which I include in a .cpp file:

typedef struct {
double x;
double y;
} pointz;

But when I compile I get:

graphics/debug.h:13: error: conflicting declaration ?typedef struct
pointz pointz?
graphics/debug.h:13: error: ?pointz? has a previous declaration as
?typedef struct pointz pointz?

But I have not previously declared ''points''.

推荐答案

desktop写道:
desktop wrote:

我在.h文件中包含此文件,我将其包含在.cpp文件中:


typedef struct {

double x;

double y;

} pointz;
I have this in a .h file which I include in a .cpp file:

typedef struct {
double x;
double y;
} pointz;



在C ++中,不要使用typedef。


struct pointz

{

双倍x;

双倍;

};


-

Ian Collins。

In C++, don''t use typedef.

struct pointz
{
double x;
double y;
};

--
Ian Collins.


" Ian Collins" < ia ****** @ hotmail.comwrote in message

news:5l ************ @ mid.individual.net ...
"Ian Collins" <ia******@hotmail.comwrote in message
news:5l************@mid.individual.net...

desktop写道:
desktop wrote:

>我在.h文件中包含此文件,我将其包含在.cpp文件中:

typedef struct {
double x;
double y;
} pointz;
>I have this in a .h file which I include in a .cpp file:

typedef struct {
double x;
double y;
} pointz;



In C ++,不要使用typedef。


struct pointz

{

double x;

双y;

};

In C++, don''t use typedef.

struct pointz
{
double x;
double y;
};



此外,你可能想要包括这两次而不包括

警卫。

In addition, it may be you are tying to include this twice without include
guards.


Ian Collins写道:
Ian Collins wrote:

desktop写道:
desktop wrote:

> ;我在.h文件中包含的.h文件中包含此文件:

typedef struct {
double x;
double y;
} pointz;
>I have this in a .h file which I include in a .cpp file:

typedef struct {
double x;
double y;
} pointz;



在C ++中,不要使用typedef。


struct pointz

{

双x;

双y;

};

In C++, don''t use typedef.

struct pointz
{
double x;
double y;
};



with


struct pointz {

double x;

double y;

};


然后我得到:

graphics / debug.h:10:错误:重新定义?struct pointz?

graphics / debug.h: 10:错误:以前定义的?struct pointz?


即使之前没有声明过。

with

struct pointz {
double x;
double y;
};

Then I just get:
graphics/debug.h:10: error: redefinition of ?struct pointz?
graphics/debug.h:10: error: previous definition of ?struct pointz?

even though its not been declared before.


这篇关于无法typedef结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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