size of struct with pointers and function pointers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sdsjohnny
    New Member
    • Jul 2010
    • 2

    #1

    size of struct with pointers and function pointers

    Hi,

    I following structure
    Code:
    typedef struct
    {
    UINT32 abc;
    int (*f)(int a, intb);
    char *ptr;
    } my_struct;
    
    main()
    {
    my_struct myParams;
    sizeof(myParams);
    }
    Assume int is 4 bytes and char is 1 byte. I know the size of structure without pointers inside. But I am not sure with pointers and function pointers. Is it 4+4+4(12) or something else??

    Thanks in advance.
    Johnny
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Yes. Size is 12.

    Regards
    Dheeraj Joshi

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      On a 32 bit system, on a 64 bit system your pointers are likely to be 8 bytes not 4.

      Comment

      Working...