What are the major differences between ANSI C and

2019-01-06 14:56发布

The Wikipedia article on ANSI C says:

One of the aims of the ANSI C standardization process was to produce a superset of K&R C (the first published standard), incorporating many of the unofficial features subsequently introduced. However, the standards committee also included several new features, such as function prototypes (borrowed from the C++ programming language), and a more capable preprocessor. The syntax for parameter declarations was also changed to reflect the C++ style.

That makes me think that there are differences. However, I didn't see a comparison between K&R C and ANSI C. Is there such a document? If not, what are the major differences?

EDIT: I believe the K&R book says "ANSI C" on the cover. At least I believe the version that I have at home does. So perhaps there isn't a difference anymore?

标签: c kr-c c89
11条回答
该账号已被封号
2楼-- · 2019-01-06 15:30

The difference is:

  1. Prototype
  2. wide character support and internationalisation
  3. Support for const and volatile keywords
  4. permit function pointers to be used as dereferencing
查看更多
smile是对你的礼貌
3楼-- · 2019-01-06 15:35
  1. function prototype.
  2. constant & volatile qualifiers.
  3. wide character support and internationalization.
  4. permit function pointer to be used without dereferencing.
查看更多
走好不送
4楼-- · 2019-01-06 15:37

The biggest single difference, I think, is function prototyping and the syntax for describing the types of function arguments.

查看更多
在下西门庆
5楼-- · 2019-01-06 15:38
  • FUNCTION PROTOTYPING:ANSI C adopts c++ function prototype technique where function definaton and declaration include function names,arguments t,data types and return value data types.function prototype enable ANSI ccompilers to check for function call in user program that passes invalid number number of argument or incompatiblle argument data types.these fix a major weakness of the K&R C compilers:invalid call in user program often passes compilation but cause program to crash when they are executed
查看更多
太酷不给撩
6楼-- · 2019-01-06 15:43

Despite all the claims to the contary K&R was and is quite capable of providing any sort of stuff from low down close to the hardware on up. The problem now is to find a compiler (preferably free) that can give a clean compile on a couple of millions of lines of K&R C without out having to mess with it.And running on something like a AMD multi core processor.

As far as I can see, having looked at the source of the GCC 4.x.x series there is no simple hack to reactivate the -traditional and -cpp-traditional lag functionality to their previous working state without without more effor than I am prepered to put in. And simpler to build a K&R pre-ansi compiler from scratch.

查看更多
Deceive 欺骗
7楼-- · 2019-01-06 15:45

There are some minor differences, but I think later editions of K&R are for ANSI C, so there's no real difference anymore.
"C Classic" for lack of a better terms had a slightly different way of defining functions, i.e.

int f( p, q, r )  
int p, float q, double r;  
{  
    // Code goes here  
}

I believe the other difference was function prototypes. Prototypes didn't have to - in fact they couldn't - take a list of arguments or types. In ANSI C they do.

查看更多
登录 后发表回答