1 /* sizes.c -- print sizes of various types
3 This file is part of the LZO real-time data compression library.
5 Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
8 The LZO library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 The LZO library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the LZO library; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/lzo/
29 #if (defined(_WIN32) || defined(_WIN64)) && defined(_MSC_VER)
30 #ifndef _CRT_NONSTDC_NO_DEPRECATE
31 #define _CRT_NONSTDC_NO_DEPRECATE 1
33 #ifndef _CRT_NONSTDC_NO_WARNINGS
34 #define _CRT_NONSTDC_NO_WARNINGS 1
36 #ifndef _CRT_SECURE_NO_DEPRECATE
37 #define _CRT_SECURE_NO_DEPRECATE 1
39 #ifndef _CRT_SECURE_NO_WARNINGS
40 #define _CRT_SECURE_NO_WARNINGS 1
44 #include "lzo/lzoconf.h"
47 #if (LZO_CC_MSC && (_MSC_VER >= 1300))
48 /* disable warning C4310: cast truncates constant value */
49 # pragma warning(disable: 4310)
92 #define print_size(type) \
93 sprintf(s,"sizeof(%s)",#type); \
94 printf("%-30s %2ld\n", s, (long)sizeof(type));
96 #define print_ssize(type,m) \
97 sprintf(s,"sizeof(%s)",#type); \
98 printf("%-30s %2ld %20ld\n", s, (long)sizeof(type), (long)(m));
100 #define print_usize(type,m) \
101 sprintf(s,"sizeof(%s)",#type); \
102 printf("%-30s %2ld %20lu\n", s, (long)sizeof(type), (unsigned long)(m));
105 int main(int argc
, char *argv
[])
109 print_ssize(char,CHAR_MAX
);
110 print_usize(unsigned char,UCHAR_MAX
);
111 print_ssize(short,SHRT_MAX
);
112 print_usize(unsigned short,USHRT_MAX
);
113 print_ssize(int,INT_MAX
);
114 print_usize(unsigned int,UINT_MAX
);
115 print_ssize(long,LONG_MAX
);
116 print_usize(unsigned long,ULONG_MAX
);
119 print_size(void (*)(void));
121 print_ssize(lzo_int
,LZO_INT_MAX
);
122 print_usize(lzo_uint
,LZO_UINT_MAX
);
123 print_size(lzo_bytep
);
125 print_size(union _lzo_align1_t
);
126 print_size(struct _lzo_align2_t
);
127 print_size(struct _lzo_align3_t
);
128 print_size(struct _lzo_align4_t
);
129 print_size(struct _lzo_align5_t
);
130 print_size(union _lzo_align6_t
);
132 if (argc
< 0 && argv
== NULL
) /* avoid warning about unused args */
138 /* vim:set ts=4 sw=4 et: */