News for hackers. Stuff that matters.
Re:Workarounds for C11 _Generic() by nstbayless on Sunday July 30, 2023 @02:39PM (#36934508)
Will this work?

  define string_length(x) _Generic(x,        \
    const char *            : strlen((const char*)(const void*)x),           \
    struct MyStringBuffer * : ((const MyStringBuffer*)(const void*)x)->length)
Re:Workarounds for C11 _Generic() by kelnos on Sunday July 30, 2023 @02:58PM (#36934700)
Heh, this was my first thought as well, and it does indeed compile and work (with GCC 12.2, anyway).
Re:Workarounds for C11 _Generic() by panzi on Sunday July 30, 2023 @08:18PM (#36937494)
Yeah, this is what I saw in some example code. Also you don't need the (void*), at least not with clang or GCC trunk on compiler explorer: https://godbolt.org/z/a8rP91dKr
Re:Workarounds for C11 _Generic() by ActorNightly on Sunday July 30, 2023 @09:08PM (#36937805)
Exactly.

Every time I read an article like this, it honestly gives me reassurance that my job isnt going to go away because of the vast, VAST amount of shit programmers out there that thing that just because a language doesn't work the way they want it to, its considered a bug.

In this article, we have someone drinking the "everything must be typed" coolaid and demanding that C pass along type information everywhere.