michael@0: /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* show the size and alignment requirements of various types */ michael@0: michael@0: #include "nsMemory.h" michael@0: #include michael@0: michael@0: struct S { michael@0: double d; michael@0: char c; michael@0: short s; michael@0: }; michael@0: michael@0: int main() michael@0: { michael@0: static const char str[] = michael@0: "Type %s has size %u and alignment requirement %u\n"; michael@0: #define SHOW_TYPE(t_) \ michael@0: printf(str, #t_, unsigned(sizeof(t_)), unsigned(NS_ALIGNMENT_OF(t_))) michael@0: michael@0: SHOW_TYPE(char); michael@0: SHOW_TYPE(unsigned short); michael@0: SHOW_TYPE(int); michael@0: SHOW_TYPE(long); michael@0: SHOW_TYPE(uint8_t); michael@0: SHOW_TYPE(int16_t); michael@0: SHOW_TYPE(uint32_t); michael@0: SHOW_TYPE(void*); michael@0: SHOW_TYPE(double); michael@0: SHOW_TYPE(short[7]); michael@0: SHOW_TYPE(S); michael@0: SHOW_TYPE(double S::*); michael@0: michael@0: return 0; michael@0: }