Top "Sizeof" questions

sizeof refers to the Standard C/C++ operator for returning the size in bytes of an expression or datatype.

What is guaranteed about the size of a function pointer?

In C, I need to know the size of a struct, which has function pointers in it. Can I be …

c pointers type-conversion function-pointers sizeof
c++ sizeof() of a class with functions

I have a C++ question. I wrote the following class: class c { int f(int x, int y){ return x; } }; …

c++ compiler-construction sizeof
How does `__declspec(align(#))` work?

Yes, I have read this: http://msdn.microsoft.com/en-us/library/83ythb65.aspx But it's not clear to me. First …

c++ visual-studio-2010 alignment sizeof declspec
What's the difference between sizeof and alignof?

What's the difference between sizeof and alignof? #include <iostream> #define SIZEOF_ALIGNOF(T) std::cout<< sizeof(…

c++ c++11 sizeof alignof
Can I get the size of a struct field w/o creating an instance of the struct?

It's trivial to get the size of a struct's field in C++ if you have an instance of the struct. …

c++ sizeof
Is there any reason not to use fixed width integer types (e.g. uint8_t)?

Assuming you're using a compiler that supports C99 (or even just stdint.h), is there any reason not to use …

c integer byte sizeof c99
how to determine sizeof class with virtual functions?

this is kind of homework question. For the following code, #include <iostream> using namespace std; class A { public: …

c++ sizeof vtable
Why the sizeof(bool) is not defined to be one, by the Standard itself?

Size of char, signed char and unsigned char is defined to be 1 byte, by the C++ Standard itself. I'm wondering …

c++ boolean standards sizeof
Why (and when) do I need to use parentheses after sizeof?

The below fails to compile: typedef int arr[10]; int main(void) { return sizeof arr; } sizeof.c:3: error: expected expression before ‘…

c sizeof
Why does "sizeof(a ? true : false)" give an output of four bytes?

I have a small piece of code about the sizeof operator with the ternary operator: #include <stdio.h> #…

c boolean sizeof conditional-operator c11