33
mrUnfused
12d

wasted my 30 minutes by calling sizeof() instead of strlen(). Daamn !!

Comments
  • 10
    sizeof isn’t really called; it’s a compiler directive not a function
  • 1
    @FrodoSwaggins oh ... just realized that... immature me !!
  • 3
    @FrodoSwaggins That was the most "It's GNU/ Linux, not Linux!" thing I have ever read.
  • 4
    @AlgoRythm if by that you mean absolutely right then yeah I guess so.

    sizeof can only work the way it does at compile time with information that is not written into the program. That’s just a fact, and has been as long as C has existed.

    sizeof is not a function. It does not run at runtime, it does not generate code, it compiles to a literal constant.
  • 1
    @FrodoSwaggins NEEEEEEEEEERD

    Doesn't matter. Nothing is really "called" because c doesn't run, asm does.

    If you really wanted to be anal about something that doesn't matter, you could say it's not callable because it's an operator.
  • 2
    @AlgoRythm I'd like to interject for a moment.
  • 1
  • 7
    @AlgoRythm What you’re referring to as sizeof, is in fact, GNU/sizeof, or as I’ve recently taken to calling it, GNU plus sizeof. sizeof is not an operating system unto itself, but rather the only free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by @FrodoSwaggins.
  • 5
    @iamavalos You made me actually laugh out loud.
  • 1
    @AlgoRythm C/C++ are meant to be baremetal anyway and require a lot of familiarity with the system to use properly, why would you object to an absolutely valid correction? There are billions of tiny details that the language depends on, the more you know the better.

    sizeof() being a compile time only thing does matter, both when judging the runtime cost and output size of a program and when using sizeof() in compile time computations or in C++ template metaprogramming. It might also trip someone up if they try to use sizeof() like a runtime function by eg. trying function pointer stuff with it.
  • 3
    @RememberMe

    *sigh*

    because the rant uses "call" as a replacement for "use".

    "by using sizeof instead of strlen"

    The correction is unnecessary, and reminds me of all those anal asshats that unironically do the GNU/Linux meme
  • 1
    @AlgoRythm I see your point, but then one could argue that your reaction is a bit extreme too.

    Anyway, I think all points have been made, don't want to let this spiral. Have a good day man, hope whatever you're working on (the C++ UI library?) goes well :)
  • 2
    @AlgoRythm that’s false. Function calls in c have a specific meaning and translate a certain way into assembly code so that they are compatible across object files and compilers, also dynamic libraries. So “calling a function” in c generates a call in assembly according to your os and platforms calling convention. Sizeof does not because it’s not a function. It collapses to a constant.

    This is actually a massive distinction, I know you don’t think it’s a big deal but it kind of is in C land.
  • 2
    OMG, I seem to trigger a debate in an serious topic. By accident I came to know about deeper stuffs. Much glad. Thank you :)
  • 2
Your Job Suck?
Get a Better Job
Add Comment