Most active commenters

    ←back to thread

    The C23 edition of Modern C

    (gustedt.wordpress.com)
    397 points bwidlar | 13 comments | | HN request time: 1.029s | source | bottom
    1. bitbasher ◴[] No.41850914[source]
    Really looking forward to #embed, once the compilers catch up. Until then, Golang.
    replies(5): >>41851074 #>>41851080 #>>41851110 #>>41851215 #>>41851883 #
    2. enriquto ◴[] No.41851074[source]
    This is not how C standards work. If it appears in the standard, it means that it is already implemented in some compilers (in that case, at least in gcc and clang).
    replies(1): >>41852554 #
    3. rfl890 ◴[] No.41851080[source]
    Clang 19 has it.
    4. jpcfl ◴[] No.41851110[source]
    Or

        xxd --include <file>
    
    :)
    replies(1): >>41852569 #
    5. f1shy ◴[] No.41851215[source]
    I do that with ld and objcopy:

    https://stackoverflow.com/questions/58815959/include-binary-...

    6. accelbred ◴[] No.41851883[source]
    I end up using a .S asm file with .incbin directives to embed files.

    #embed would be much nicer

    replies(1): >>41853705 #
    7. pjmlp ◴[] No.41852554[source]
    That isn't really how it goes, that is how it used to be up to C99.
    replies(1): >>41852590 #
    8. Keyframe ◴[] No.41852569[source]
    The anti-Rust approach!
    9. enriquto ◴[] No.41852590{3}[source]
    Thanks for the correction! Do you know if there is a document from the standards body explaining the change in philosophy?
    replies(2): >>41853226 #>>41853692 #
    10. MathMonkeyMan ◴[] No.41853226{4}[source]
    I've heard something along the lines of "the standard is to define facilities that will be used in most programs, and to codify widespread existing practice." That was in the context of "I don't like this proposed feature," though. This was for C++, not C.

    A lot of stuff in the C++11 standard library was based on widespread use of Boost. Since then, I don't know. Also, were things like templates and lambdas implemented as compiler extensions before standardization? I don't know, but I doubt it. Maybe "we're a committee of people who will decide on a thing and we hope you like it" was always the norm in many ways.

    11. JonChesterfield ◴[] No.41853692{4}[source]
    It's a nuisance to implement the thing you want to add to the standard yourself. It's easier to ship it in the language and then complain at compiler devs that they're running behind the edge of progress.

    This interacts in the obvious way with refusing to correct mistakes after the fact for fear of breaking user code.

    I don't believe anyone has written a paper along the lines of "let's not bother with the existing practice part anymore", it's more an emergent feature of people following local incentive structures.

    12. JonChesterfield ◴[] No.41853705[source]
    Incbin works just fine from inline asm fwiw
    replies(1): >>41856465 #
    13. flohofwoe ◴[] No.41856465{3}[source]
    Inline assembly isn't supported for x86-64 and ARM on MSVC which unfortunately also means the incbin trick can't be used there anymore.