sizeof function implementation using C programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ravichobey
    New Member
    • Mar 2008
    • 6

    #1

    sizeof function implementation using C programming

    Hi all,

    How to implement sizeof() function using C programming?

    Regards,
    Ravi
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by ravichobey
    Hi all,

    How to implement sizeof() function using C programming?

    Regards,
    Ravi
    You can't do that because the compile time function sizeof needs access to
    the compiler's symbol table for the type information, e.g. what would "sizeof(T)"
    be withouth knowing what T would be? T can be a typedef identifier or an ordinary
    identifier with a type. You don't have that information anymore when your program
    is running.

    kind regards,

    Jos

    Comment

    • mac11
      Contributor
      • Apr 2007
      • 256

      #3
      There was a thread on this very subject not long ago, see here:
      Join 420,000+ software developers and IT professionals


      Wow! Jos types fast!

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by mac11
        TWow! Jos types fast!
        Yup, my asbestos keyboard can hardly stand the heat :-)

        kind regards,

        Jos

        Comment

        Working...