typedef的问题 [英] Problems with typedef

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

问题描述



大家好,


我对以下内容感到困惑,这导致我们的用户之一

's代码编译失败:


typedef struct SctpDest_S;


1)这是标准吗?

2)如果是这样(或者即使不是这样!)该怎么办?


错误信息是


" A typedef声明必须声明一个名称。


这似乎有意义!很抱歉,如果我错过了明显的

,但它与常见问题解答中的1.17无关,是吗?


基于类似的理由,他有typedef的表格


typedef struct SctpHeartbeatChunk_S

{

SctpChunkHdr_S sHdr;

u_short usInfoType;

u_short usInfoLength;

double dTimestamp;

SctpDest_S * spDest;

};


再次是这个标准,它应该做什么? (虽然这一次

我可能会猜到)


对不起,如果这很明显,看看K& R2我找不到它C非常多b / b
我的第二语言(我是Fortran家伙),

Ian


Hi All,

I''m a bit confused by the following which is causing one of
our user''s codes fail in compilation:

typedef struct SctpDest_S;

1) Is this standard ?
2) If so ( or even if not so ! ) what is it supposed to do ?

The error message is

"A typedef declaration must declare a name."

which seems to make sense ! Sorry if I missing the obvious
but it''s not related to 1.17 in the FAQ, is it ?

On similar grounds he has typedefs of the form

typedef struct SctpHeartbeatChunk_S
{
SctpChunkHdr_S sHdr;
u_short usInfoType;
u_short usInfoLength;
double dTimestamp;
SctpDest_S *spDest;
};

Again is this standard and what is it supposed to do ? ( though this time
I might be able to guess )

Sorry if this is obvious, looking in K&R2 I can''t find it and C is very much
my second language (I''m a Fortran guy),
Ian

推荐答案

伊恩·布什写道:
我对以下内容感到困惑,导致其中一个用户的代码在编译时失败:

typedef struct SctpDest_S;

1)这是标准吗?
2)如果是这样(或者即使不是这样!)它应该做什么?

错误信息是

typedef声明必须声明一个名称。

这似乎有意义!对不起,如果我错过了明显的
但它与常见问题解答中的1.17无关,是吗?


typedef为现有的

类型创建一个新名称(我称之为同义词),因此您需要提供两个名称,旧的和新的。


你只给一个:SctpDest_S


它应该是


typedef struct SctpDest_S new_name;





typedef struct old_name SctpDest_S;

基于类似理由他有形式的typedef

typedef struct SctpHeartbeatChunk_S
{sctpChunkHdr_S sHdr;
u_short usInfoType;
u_short usInfoLength;
double dTimestamp;
SctpDest_S * spDest;
};

这个标准又是什么呢?它应该做什么? (虽然这次我可能会猜到)

对不起,如果这是显而易见的,看看K& R2我找不到它而且C非常多
我的第二语言(我是Fortran家伙),
I''m a bit confused by the following which is causing one of
our user''s codes fail in compilation:

typedef struct SctpDest_S;

1) Is this standard ?
2) If so ( or even if not so ! ) what is it supposed to do ?

The error message is

"A typedef declaration must declare a name."

which seems to make sense ! Sorry if I missing the obvious
but it''s not related to 1.17 in the FAQ, is it ?
A typedef creates a new name (I call it a "synonym") for an existing
type, so you need to provide two names, the old and the new.

You are giving only one: SctpDest_S

It should be either

typedef struct SctpDest_S new_name;

or

typedef struct old_name SctpDest_S;
On similar grounds he has typedefs of the form

typedef struct SctpHeartbeatChunk_S
{
SctpChunkHdr_S sHdr;
u_short usInfoType;
u_short usInfoLength;
double dTimestamp;
SctpDest_S *spDest;
};

Again is this standard and what is it supposed to do ? ( though this time
I might be able to guess )

Sorry if this is obvious, looking in K&R2 I can''t find it and C is very much
my second language (I''m a Fortran guy),



Roberto Waltman写道:
Roberto Waltman wrote:
Ian Bush写道:
Ian Bush wrote:
我对以下内容感到困惑,导致我们用户的代码之一在编译时失败:

typedef struct SctpDest_S;

1)这是标准吗?
2)如果是这样(或者即使不是这样!)该怎么办?

错误信息是

一个typedef声明必须声明一个名称。

这似乎有意义!很抱歉,如果我错过了明显的
但它与FAQ中的1.17无关,是吗?
I''m a bit confused by the following which is causing one of
our user''s codes fail in compilation:

typedef struct SctpDest_S;

1) Is this standard ?
2) If so ( or even if not so ! ) what is it supposed to do ?

The error message is

"A typedef declaration must declare a name."

which seems to make sense ! Sorry if I missing the obvious
but it''s not related to 1.17 in the FAQ, is it ?



一个typedef创建一个新名称(我称之为 ;同义词")对于现有的
类型,所以你需要提供两个名称,旧的和新的。

你只给一个:SctpDest_S

它应该是

typedef struct SctpDest_S new_name;


typedef struct old_name SctpDest_S;



A typedef creates a new name (I call it a "synonym") for an existing
type, so you need to provide two names, the old and the new.

You are giving only one: SctpDest_S

It should be either

typedef struct SctpDest_S new_name;

or

typedef struct old_name SctpDest_S;



是的,我理解这一点。然而,我的用户没有,我想知道是否在

任何情况下它可能意味着什么,如果是这样的话是什么情况

这是什么意思?


谢谢,


Ian



Yes, I understand this. However my user has not and I am wondering if under
any circumstances it may mean anything, and if so what are those circumstances
and what does it mean ?

Thanks,

Ian


----- BEGIN PGP签名消息-----

哈希:SHA1

Roberto Waltman写道:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Roberto Waltman wrote:
Ian Bush写道:
Ian Bush wrote:
我对以下内容感到有点困惑,这导致我们的用户代码之一在编译时失败:

typedef struct SctpDest_S;

1)这是标准吗?
2)如果是这样(或者即使不是这样!)该怎么办?

错误信息是

A typedef声明必须声明一个名称。

这似乎有意义!对不起,如果我错过了明显的
但它与常见问题解答中的1.17无关,是吗?
一个typedef为现有的<创建一个新名称(我称之为同义词) br />类型,所以你需要提供两个名称,旧的和新的。
I''m a bit confused by the following which is causing one of
our user''s codes fail in compilation:

typedef struct SctpDest_S;

1) Is this standard ?
2) If so ( or even if not so ! ) what is it supposed to do ?

The error message is

"A typedef declaration must declare a name."

which seems to make sense ! Sorry if I missing the obvious
but it''s not related to 1.17 in the FAQ, is it ?
A typedef creates a new name (I call it a "synonym") for an existing
type, so you need to provide two names, the old and the new.




ITYM

所以你需要提供一个类型和名称。

你只给一个:SctpDest_S


ITYM

"你只给名称

应该是

typedef struct SctpDest_S new_name;


,其中包含类型struct SctpDest_S"和一个名称new_name



typedef struct old_name SctpDest_S;



ITYM
"so you need to provide a type and a name".
You are giving only one: SctpDest_S
ITYM
"You are giving only the name"
It should be either

typedef struct SctpDest_S new_name;
which contains a type "struct SctpDest_S" and a name "new_name"
or

typedef struct old_name SctpDest_S;




包含一个类型" ; struct old_name"和一个名字SctpDest_S



which contains a type "struct old_name" and a name "SctpDest_S"

基于类似的理由,他有类型的typedef

typedef struct SctpHeartbeatChunk_S {
SctpChunkHdr_S sHdr;
u_short usInfoType;
u_short usInfoLength;
double dTimestamp;
SctpDest_S * spDest;
};


,其类型为struct SctpHeartbeatChunk_S {...}但没有名字。

这个标准又是什么呢?它应该做什么? (虽然这次我可能会猜到)


AFAIK,这不是标准,也不应该编译。这是一个

不完整的typedef,缺少给定类型的typedef名称。

对不起,如果这很明显,看看K& R2我可以'找不到它,C非常多我的第二语言(我是Fortran家伙),
On similar grounds he has typedefs of the form

typedef struct SctpHeartbeatChunk_S
{
SctpChunkHdr_S sHdr;
u_short usInfoType;
u_short usInfoLength;
double dTimestamp;
SctpDest_S *spDest;
};
which has a type of "struct SctpHeartbeatChunk_S { ... }" but no name.
Again is this standard and what is it supposed to do ? ( though this time
I might be able to guess )
AFAIK, this isn''t standard, and it should not compile. It is an
incomplete typedef, lacking a name to be typedef''ed to the given type.
Sorry if this is obvious, looking in K&R2 I can''t find it and C is very much
my second language (I''m a Fortran guy),



----- BEGIN PGP SIGNATURE- ----

版本:GnuPG v1.4.3(MingW32) - WinPT 0.11.12

iD8DBQFEo9yTagVFX4UWr64RAqwOAKCuTRe2TSQZHqXbBkLL VLR29 + ngCfVS4a

WGlbAVDN0yOfTGv3SjRgOrs =

= AL4R

-----结束PGP签名-----


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12

iD8DBQFEo9yTagVFX4UWr64RAqwOAKCuTRe2TSQZHqXbBk23Lv VLR29+ngCfVS4a
WGlbAVDN0yOfTGv3SjRgOrs=
=AL4R
-----END PGP SIGNATURE-----


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

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