size of a datatype without using sizeof

后端 未结 21 2000
慢半拍i
慢半拍i 2020-12-01 02:34

I have a data type, say X, and I want to know its size without declaring a variable or pointer of that type and of course without using sizeof oper

21条回答
  •  日久生厌
    2020-12-01 03:01

    put this to your code

    then check the linker output ( map file)

    unsigned int  uint_nabil;
    unsigned long  ulong_nabil;
    

    you will get something like this ;

    uint_nabil 700089a8 00000004
    ulong_nabil 700089ac    00000004
    

    4 is the size !!

提交回复
热议问题