我可以使用C99功能吗? [英] Can I use C99 features yet?

查看:93
本文介绍了我可以使用C99功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用仅限C99的功能被认为是个坏主意吗?它几乎已经是6年了吗?特别是我对可变参数宏很感兴趣。所有

我的代码是C89(或更少),除了我的调试宏。


谢谢,

Mike

解决方案

Michael B Allen< mb ***** @ ioplex.com>写道:

使用仅C99功能是否是一个坏主意?它差不多6年了吗?特别是我对可变参数宏很感兴趣。所有的代码都是C89(或更少),除了我的调试宏。




我会说C99还不够实现,如果

你希望你的代码是可移植的。

-

Ben Pfaff

电子邮件:< a href =mailto:bl*@cs.stanford.edu> bl*@cs.stanford.edu

web: http://benpfaff.org


Michael B Allen写道:

使用仅C99功能被认为是一个坏主意吗? [...]


是的。但是在这个新闻组中,谈论C99

(比一些人的想象力更多)比Visual

C ++或gcc(其中一个)更合适。几乎可以肯定的是你使用的编译器

。)

[...]已经差不多6年了吗? [...]


我认为技术上只有5年多一点。但主要的

内容已知大约6年。

[...]特别是我对可变参数宏感兴趣。所有我的代码都是C89(或更少),除了我的调试宏。




哦,很糟糕,很难成为你。也许你自己可以用这个扩展程序编写一个便携式的C / $
预处理器 - 至少可以给出一些合理的可移植性前景。 C99功能只是没有便携式(几乎没有人完全实现它,并且它的高度不可能是任何主流编译器所能实现的。)可以在C中移植

你必须坚持16年的标准,因为从那时起C标准

委员会一般都被忽略了。


其实,如果您正在寻找采用新的语言功能(例如

可变参数宏),请尝试在下一个* C ++ *标准中推送它们,因为

它们将更有可能被采用(并可能返回

移植到C编译器)。


-

Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/


在消息< pa ********************************* @ ioplex.com>

Michael B Allen< mb*****@ioplex.com>写道:

使用仅C99功能是否是一个坏主意?它差不多6年了吗?特别是我对可变参数宏很感兴趣。所有我的代码都是C89(或更少),除了我的调试宏。




由您决定。这取决于你认为你可能在不久的将来使用的实现是否支持你需要的特定C99功能。


我们广泛使用C99这里 - 主要是核心语言的东西,如指定

初始化器,VLA,可变参数宏和布尔。还< stdint.h>非常方便,

和snprintf。我们在调试库中使用了可变参数宏。


但是,我们几乎只使用一个编译器。我们唯一可能使用的其他编译器是gcc,它支持所有或大部分功能。


任何更深奥的东西,尤其是数学部分,例如

< complex.h>和附件F的可移植性可能差得多。大多数编译器

甚至不提供C89浮点数,更不用说C99附件F.


显然任何使用C99功能都会减少你的代码便携式比使用

C89功能。但是,使用C89功能会使您的代码比

pcc代码更不便携。这取决于你应该在哪里绘制线条。


-

Kevin Bracey,首席软件工程师

Tematic Ltd电话:+44(0)1223 503464

182-190 Newmarket Road传真:+44(0)1728 727430

剑桥,CB5 8HE,英国WWW: http://www.tematic.com/


Is it considered a bad idea to use a C99 only feature? It has been almost
6 years right? Specifically I''m interested in variadic macros. All of
my code is C89 (or less) except for my debugging macros.

Thanks,
Mike

解决方案

Michael B Allen <mb*****@ioplex.com> writes:

Is it considered a bad idea to use a C99 only feature? It has been almost
6 years right? Specifically I''m interested in variadic macros. All of
my code is C89 (or less) except for my debugging macros.



I''d say that there still aren''t enough C99 implementations, if
you want your code to be portable.
--
Ben Pfaff
email: bl*@cs.stanford.edu
web: http://benpfaff.org


Michael B Allen wrote:

Is it considered a bad idea to use a C99 only feature? [...]
Yes. But in this newsgroup its more appropriate to talk about C99
(little more than a figment of some people''s imagination) than Visual
C++ or gcc (one of which is almost certainly the compiler you are
using.)
[...] It has been almost 6 years right? [...]
I think technically just a little more than 5 years. But the major
contents were known for about 6 years.
[...] Specifically I''m interested in variadic macros. All of
my code is C89 (or less) except for my debugging macros.



Oh well, sucks to be you. Maybe you could write a portable C
preprocessor with this extension yourself -- that would at least give
some reasonable prospect of portability. The C99 features are just not
portable (almost nobody implements it completely, and its highly
unlikely that any mainstream compiler ever will.) To be portable in C
you have to stick with the 16 year old standard, since the C standard
committee has generally been ignored since then.

Actually, if you are looking for adopting new language features (like
variadic macros) try pushing for them in the next *C++* standard, since
they will then be far more likely to be adopted (and possibly back
ported to the C compiler).

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/


In message <pa*********************************@ioplex.com>
Michael B Allen <mb*****@ioplex.com> wrote:

Is it considered a bad idea to use a C99 only feature? It has been almost
6 years right? Specifically I''m interested in variadic macros. All of
my code is C89 (or less) except for my debugging macros.



Up to you. It depends whether the implementations you think you''re likely to
use in the near future support the particular C99 feature you need.

We use C99 extensively here - mainly the core language stuff like designated
initialisers, VLAs, variadic macros and bool. Also <stdint.h> is very handy,
and snprintf. We use variadic macros for our debugging library.

However, we pretty much only use one compiler. The only other compiler we''re
likely to use is gcc, which supports all or most of those features.

Any of the more esoteric stuff, particularly the math parts such as
<complex.h> and Annex F are likely to be far less portable. Most compilers
don''t even provide C89 floating-point, let alone C99 Annex F.

Obviously any use of a C99 feature makes your code less portable than using
C89 features. But then, using C89 features makes your code less portable than
pcc code. It''s up to you where you think the line should be drawn.

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1728 727430
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/


这篇关于我可以使用C99功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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