summaryrefslogtreecommitdiffstats
path: root/checktypes.c
blob: 43a197d780ee24b62d18f37fadad70d6be3ea007 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (C) 1999-2000 Thomas Roessler <roessler@guug.de>
 * 
 *     This program is free software; you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation; either version 2 of the License, or
 *     (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with this program; if not, write to the Free Software
 *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 */ 

/* Check various types for their respective length */

#include <stdio.h>

#define CHECK_TYPE(a,b)					\
	if (!have_UINT##a && (sizeof (b) == a)) 	\
	{						\
	  have_UINT##a = 1;				\
	  puts (" #define UINT" #a " " #b);		\
	}

int main (int argc, char *argv[])
{
  short have_UINT2 = 0;
  short have_UINT4 = 0;
  
  puts ("/* This is a generated file.  Don't edit! */");
  puts ("#ifndef _TYPES_H");
  puts (" #define _TYPES_H");

  CHECK_TYPE (2, unsigned short int)
  CHECK_TYPE (2, unsigned int)
  CHECK_TYPE (4, unsigned short int)
  CHECK_TYPE (4, unsigned int)
  CHECK_TYPE (4, unsigned long int)
  
  puts ("#endif");
  
  if (!have_UINT2 || !have_UINT4)
  {
    fputs ("Can't determine integer types.  Please edit " __FILE__ ",\n", stderr);
    fputs ("and submit a patch to <mutt-dev@mutt.org>\n", stderr);
    return 1;
  }
  
  return 0;
}