Compatibility of C89/C90, C99 and C11

后端 未结 4 1342
梦如初夏
梦如初夏 2021-02-14 03:15

I just read: C Wikipedia entry. As far as I know there are 3 different versions of C that are widely used: C89, C99 and C11. My question concerns the compatibility of source cod

4条回答
  •  粉色の甜心
    2021-02-14 03:43

    Are the newer versions of C i.e. C99, C11 supersets of older C versions?

    There are many differences, big and subtle both. Most changes were adding of new features and libraries. C99 and C11 are not supersets of C90, although there was a great deal of effort made to ensure backwards-compatibility. C11 is however mostly a superset of C99.

    Still older code could break when porting from C90, in case the code was written poorly. Particularly various forms of "implicit int" and implicit function declarations were banned from the language with C99. C11 banned the gets function.

    A complete list of changes can be found in the C11 draft page 13 of the pdf, where "the third edition" refers to C11 and "the second edition" refers to C99.

    How to 'port' old code to the new versions? Is there a document which explains this procedure?

    I'm not aware about any such document. If you have good code, porting is easy. If you have rotten code, porting will be painful. As for the actual porting procedure, it will be easy if you know the basics of C99 and C11, so the best bet is to find a reliable source of learning which addresses C99/C11.

    Porting from C99 to C11 should be effortless.

    Is it better to use C89 or C99 or C11?

    It is best to use C11 as that is the current standard. C99 and C11 both contained various "language bug fixes" and introduced new, useful features.

提交回复
热议问题