Announcement

Collapse
No announcement yet.

Linus Rejects "Size Of Member" Change From Linux 5.5 Kernel

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Originally posted by betam4x View Post
    On an unrelated note, it always baffles me why certain groups of developers like to use underscores in their functions. IMO sizeOfMember or SizeOfMember are both quicker and easier to type. The distance of the _ character is much further than the shift key. There are also fewer characters.
    Umm, why are you coding with a single hand? Here I have the _ under my right hand when I type.

    Comment


    • #32
      Originally posted by kpedersen View Post
      I don't know if this belongs in stddef.h; possibly nonstandard/linux/defs.h?

      This MACRO isn't too daft though; the one I possibly wish they would stop using is offsetof. This is non-standard code and requires hacks in the compiler itself (currently just clang and gcc support it).

      Originally posted by brainlet_pederson

      Fortunately, unlike you, the kernel developers realize that offsetof has been part of standard C for 20 years (since ISO C99).

      ....do you even code bro?
      I was curious about this disagreement, so I looked it up. You're sort of both right. offsetof is in C99, so we should rightfully expect compilers to implement it. However, some of its traditional implementations, like the one I remember from the Quake code, involve undefined behavior, and some compilers have implemented hacks to accomodate this. It's also not possible to implement this type of macro for all C++ types, not that that matters in the kernel.

      Also, did you go through the entire sign up process with the name brainlet_pederson just so you could make one post and be an asshole? pretty sad bro

      Comment


      • #33
        Originally posted by microcode View Post
        I have read the standard, but the standard came after the language. Structs are records, records have fields, structs might have members, but members are fields.
        My memory of it is hazy, but I think the pre-ANSI K+R book still called them members. I may be wrong though.

        In any case, we're not actually disagreeing. I wasn't as clear as I could have been - I was trying to say that it's more usual/expected when dealing with something in a specific context (C code vs. programming concept) to use the name of that context. For instance, it would be correct to call a structure a record in the context of C code, though perhaps a little unusual. As long as terminology is consistent, I don't think it actually matters though.

        Originally posted by MaxToTheMax View Post
        Also, did you go through the entire sign up process with the name brainlet_pederson just so you could make one post and be an asshole? pretty sad bro
        Likely a regular forum member who didn't want their main account to get targeted.

        Comment


        • #34
          Originally posted by brainlet_pederson
          No part of his statement is "right". A standard language feature of 20 years is not a "hack", nor does offsetof() require anything resembling a hack to implement. At least half a dozen other compilers (in addition to GCC and Clang) support it.
          This is a hack:
          Code:
          #define offsetof(st, m) ((size_t)&(((st *)0)->m))
          There are non-hackish implementations, but many codebases still employ this one, requiring some compilers to accomodate it.

          The QuakeC language is not C and was only designed for use in a single application (where standards compliance is irrelevant).
          I wasn't talking about QuakeC, silly. I was talking about these:

          https://github.com/tastyspleen/r1q2-...g_local.h#L508
          https://github.com/ioquake/ioq3/blob...g_local.h#L695

          Quake 2 and 3 don't employ QuakeC at all. I spent many years working with this family of game engines, don't try to correct me on this

          Why do you keep trying to state a point about C by mentioning every language except C? C++ is not C.
          Because it's a huge audience of developers that would naturally be wary of offsetof. They would be wrong to do so in a C99 (or newer) codebase, but empathy is a nice thing to have.

          The sign-up process takes 10 seconds. It was worth it to correct a cocky c*nt being wrong on the internet...
          It's pretty clear to me which of you has the bigger chip on his shoulder.
          Last edited by MaxToTheMax; 12 December 2019, 12:55 PM.

          Comment

          Working...
          X