常问题 [英] const question

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

问题描述

这看起来有点奇怪,但我有一些简单的问题。基本上,我是
写一个非常简单的解析器,它理解C类型的声明 -

唯一的原因是,所以我更了解C。所以这里是:


/ *这意味着''const int''?? * /

const c = 0;


/ *这是合法的C?它是由''真正的''C编译器允许但我不确定* /

const const const int c = 0;


/ *与此相同??? * /

unsigned unsigned unsigned int u = 0;


谢谢,

James

解决方案

在文章< Xd ******************** @ pipex.net>中,

James Brown< no*@home.netwrote:


> / *这是合法的C?它是由''真正的''C编译器允许的,但我不确定* /
const const const int c = 0;



C89 3.5.3类型限定符


相同的类型限定符在
$中不会出现多次b $ b相同的说明符列表或限定符列表,可以通过一个或多个typedef直接或



-

编程是怎么回事当你忙于制定其他计划时。


" Walter Roberson" < ro ****** @ ibd.nrc-cnrc.gc.cawrote in message

news:ei ********** @ canopus.cc.umanitoba.ca ...


在文章< Xd ******************** @ pipex.net>中,

James Brown< no*@home.netwrote:


>> / *这是合法的C?它是由''真正的''C编译器允许的,但我不确定
* /
const const const int c = 0;



C89 3.5.3类型限定符


相同的类型限定符不会出现多次

相同的说明符列表或限定符列表,可以通过一个或多个typedef直接或



-



ok谢谢你清理那个....所以如果我正确理解上面的

段落,则以下内容无效:


typedef const int cint;


const cint c; / *根据C89无效3.5.3 * /


谢谢,

James


2006 -11-01< Xd ******************** @ pipex.net>,

James Brown写道:
< blockquote class =post_quotes>
这看起来有点奇怪,但我有一些简单的问题。基本上,我是
写一个非常简单的解析器,它理解C类型的声明 -

唯一的原因是,所以我更了解C。所以这里是:


/ *这意味着''const int''?? * /

const c = 0;



这个没有回答。我相信c89的答案是肯定的,而不是

c99。 ''int''对于c89来说很少是绝对必要的,实际上,因为你通常可以在没有它的情况下编写你的程序(但你为什么要这样做?)


This may seem a little odd but I have a few simple questions. Basically, I''m
writing a really simple parser which understands C type declarations - the
only reason being, so that I understand C better. So here goes:

/* does this imply ''const int'' ?? */
const c = 0;

/* is this legal C? it''s allowed by my ''real'' C compiler but I''m not sure */
const const const int c = 0;

/* same for this??? */
unsigned unsigned unsigned int u = 0;

thanks,
James

解决方案

In article <Xd********************@pipex.net>,
James Brown <no*@home.netwrote:

>/* is this legal C? it''s allowed by my ''real'' C compiler but I''m not sure */
const const const int c = 0;

C89 3.5.3 Type Qualifiers

The same type qualifier shall not appear more than once in
the same specifier list or qualifer list, either directly or
via one or more typedefs.
--
Programming is what happens while you''re busy making other plans.


"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.cawrote in message
news:ei**********@canopus.cc.umanitoba.ca...

In article <Xd********************@pipex.net>,
James Brown <no*@home.netwrote:

>>/* is this legal C? it''s allowed by my ''real'' C compiler but I''m not sure
*/
const const const int c = 0;


C89 3.5.3 Type Qualifiers

The same type qualifier shall not appear more than once in
the same specifier list or qualifer list, either directly or
via one or more typedefs.
--

ok thanks for clearing that one up....so if I''m understanding the above
paragraph correctly, the following is therefore invalid:

typedef const int cint;

const cint c; /* invalid as per C89 3.5.3 */

thanks,
James


2006-11-01 <Xd********************@pipex.net>,
James Brown wrote:

This may seem a little odd but I have a few simple questions. Basically, I''m
writing a really simple parser which understands C type declarations - the
only reason being, so that I understand C better. So here goes:

/* does this imply ''const int'' ?? */
const c = 0;

This one wasn''t answered. I believe the answer is yes for c89, no for
c99. ''int'' is rarely strictly necessary for c89, actually, in that you
can usually write your program without it (but why would you want to?)


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

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