• Migration from C89/C99 to C11/C17

    From =?UTF-8?B?0KHQtdGA0LPQtdC5INCR0LDRgdGL0YDQvtCy?=@pmswga@gmail.com to comp.std.c on Wed Aug 25 20:52:17 2021
    From Newsgroup: comp.std.c

    Hello everyone!

    What do you think about code migration of legacy C code to new C standarts?

    And what tools can help to do that?
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From David Brown@david.brown@hesbynett.no to comp.std.c on Thu Aug 26 10:05:48 2021
    From Newsgroup: comp.std.c

    On 26/08/2021 05:52, Сергей Басыров wrote:
    Hello everyone!

    What do you think about code migration of legacy C code to new C standarts?

    And what tools can help to do that?


    You usually don't need to do anything.

    Code that is good C99 is almost certainly equally good as C11, as the
    changes between C99 and C11 are primarily the addition of features such
    as atomics and threading, generics, and standardisation of some common
    compiler extensions. C17 is just a bug-fix of C11, and the changes only
    affect quite obscure corner cases (AFAIUI).


    The big difference was C89/C90 to C99. Again, most of it was new
    features that are not going to affect existing code unless you happen to
    use some of the new keywords as identifiers. But there are occasional differences, such as the types of some integer constants and possible differences in rounding for division with negative integers.


    If you have specific questions or code that you'd like help with,
    comp.lang.c is probably a better newsgroup.
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From Sergey Basyrov@pmswga@gmail.com to comp.std.c on Thu Aug 26 03:51:48 2021
    From Newsgroup: comp.std.c

    четверг, 26 августа 2021 г. в 11:05:52 UTC+3, David Brown:
    On 26/08/2021 05:52, Сергей Басыров wrote:
    Hello everyone!

    What do you think about code migration of legacy C code to new C standarts?

    And what tools can help to do that?

    You usually don't need to do anything.

    Code that is good C99 is almost certainly equally good as C11, as the changes between C99 and C11 are primarily the addition of features such
    as atomics and threading, generics, and standardisation of some common compiler extensions. C17 is just a bug-fix of C11, and the changes only affect quite obscure corner cases (AFAIUI).


    The big difference was C89/C90 to C99. Again, most of it was new
    features that are not going to affect existing code unless you happen to
    use some of the new keywords as identifiers. But there are occasional differences, such as the types of some integer constants and possible differences in rounding for division with negative integers.


    If you have specific questions or code that you'd like help with, comp.lang.c is probably a better newsgroup.
    Thank you David!
    So, I can just change "-std" option of gcc and C program will work better?
    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From David Brown@david.brown@hesbynett.no to comp.std.c on Thu Aug 26 14:49:59 2021
    From Newsgroup: comp.std.c

    On 26/08/2021 12:51, Sergey Basyrov wrote:
    четверг, 26 августа 2021 г. в 11:05:52 UTC+3, David Brown:
    On 26/08/2021 05:52, Сергей Басыров wrote:
    Hello everyone!

    What do you think about code migration of legacy C code to new C standarts?

    And what tools can help to do that?

    You usually don't need to do anything.

    Code that is good C99 is almost certainly equally good as C11, as the
    changes between C99 and C11 are primarily the addition of features such
    as atomics and threading, generics, and standardisation of some common
    compiler extensions. C17 is just a bug-fix of C11, and the changes only
    affect quite obscure corner cases (AFAIUI).


    The big difference was C89/C90 to C99. Again, most of it was new
    features that are not going to affect existing code unless you happen to
    use some of the new keywords as identifiers. But there are occasional
    differences, such as the types of some integer constants and possible
    differences in rounding for division with negative integers.


    If you have specific questions or code that you'd like help with,
    comp.lang.c is probably a better newsgroup.

    Thank you David!

    So, I can just change "-std" option of gcc and C program will work better?


    No, it will work exactly alike (baring these very few corner cases).
    You don't get the advantage of newer C standards unless you write code
    that uses them. And most of the benefits are about making it easier to
    write clearer and safer C code, there will normally be no effect on the
    speed, size or correctness of the resulting compiled code. C99 lets you
    write better source code than C90, it does not let you get better
    results from old code.


    --- Synchronet 3.19a-Linux NewsLink 1.113
  • From Sergey Basyrov@pmswga@gmail.com to comp.std.c on Thu Aug 26 08:10:21 2021
    From Newsgroup: comp.std.c

    четверг, 26 августа 2021 г. в 15:50:03 UTC+3, David Brown:
    On 26/08/2021 12:51, Sergey Basyrov wrote:
    четверг, 26 августа 2021 г. в 11:05:52 UTC+3, David Brown:
    On 26/08/2021 05:52, Сергей Басыров wrote:
    Hello everyone!

    What do you think about code migration of legacy C code to new C standarts?

    And what tools can help to do that?

    You usually don't need to do anything.

    Code that is good C99 is almost certainly equally good as C11, as the
    changes between C99 and C11 are primarily the addition of features such >> as atomics and threading, generics, and standardisation of some common
    compiler extensions. C17 is just a bug-fix of C11, and the changes only >> affect quite obscure corner cases (AFAIUI).


    The big difference was C89/C90 to C99. Again, most of it was new
    features that are not going to affect existing code unless you happen to >> use some of the new keywords as identifiers. But there are occasional
    differences, such as the types of some integer constants and possible
    differences in rounding for division with negative integers.


    If you have specific questions or code that you'd like help with,
    comp.lang.c is probably a better newsgroup.

    Thank you David!

    So, I can just change "-std" option of gcc and C program will work better?

    No, it will work exactly alike (baring these very few corner cases).
    You don't get the advantage of newer C standards unless you write code
    that uses them. And most of the benefits are about making it easier to
    write clearer and safer C code, there will normally be no effect on the speed, size or correctness of the resulting compiled code. C99 lets you write better source code than C90, it does not let you get better
    results from old code.
    Okay. I understood.
    Thank you very much!
    --- Synchronet 3.19a-Linux NewsLink 1.113