source: libcaca/trunk/caca/caca_types.h.in @ 4396

Last change on this file since 4396 was 4396, checked in by Sam Hocevar, 11 years ago

On Win32 and Win64, define 32-bit C99 types as ints instead of longs, because
a lot of software (wrongly) assumes that int32_t is the same as int.

File size: 3.0 KB
Line 
1/*
2 *  libcaca       Colour ASCII-Art library
3 *  libcaca       Colour ASCII-Art library
4 *  Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
5 *                All Rights Reserved
6 *
7 *  This library is free software. It comes without any warranty, to
8 *  the extent permitted by applicable law. You can redistribute it
9 *  and/or modify it under the terms of the Do What The Fuck You Want
10 *  To Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14/*
15 *  This file contains definitions for the C99 integer types.
16 */
17
18#ifndef __CACA_TYPES_H__
19#define __CACA_TYPES_H__
20
21#ifndef CACA_TYPES
22#   define CACA_TYPES @CACA_TYPES@
23#endif
24
25/* mode 1: standard <stdint.h> header is present, just include it */
26#if CACA_TYPES == 1
27#   include <stdint.h>
28#   include <unistd.h>
29
30/* mode 2: standard <inttypes.h> header is present, just include it */
31#elif CACA_TYPES == 2
32#   include <inttypes.h>
33#   include <unistd.h>
34
35/* mode 3: Win32, only (u)intptr_t is present */
36#elif CACA_TYPES == 3
37#include <windows.h>
38
39typedef signed char int8_t;
40typedef signed short int16_t;
41typedef signed int int32_t;
42typedef signed long long int int64_t;
43
44typedef unsigned char uint8_t;
45typedef unsigned short uint16_t;
46typedef unsigned int uint32_t;
47typedef unsigned long long int uint64_t;
48
49typedef int ssize_t;
50typedef unsigned int size_t;
51
52/* mode 4: Win64, only (u)intptr_t and size_t are present */
53#elif CACA_TYPES == 4
54#include <windows.h>
55
56typedef signed char int8_t;
57typedef signed short int16_t;
58typedef signed int int32_t;
59typedef signed long long int int64_t;
60
61typedef unsigned char uint8_t;
62typedef unsigned short uint16_t;
63typedef unsigned int uint32_t;
64typedef unsigned long long int uint64_t;
65
66typedef int ssize_t;
67
68/* fallback: nothing is known, we assume the platform is 32-bit and
69 * sizeof(long) == sizeof(void *). We don't typedef directly because we
70 * have no idea what other typedefs have already been made. */
71#else
72typedef signed char _caca_int8_t;
73typedef signed short _caca_int16_t;
74typedef signed long int _caca_int32_t;
75typedef signed long long int _caca_int64_t;
76#   undef int8_t
77#   define int8_t _caca_int8_t
78#   undef int16_t
79#   define int16_t _caca_int16_t
80#   undef int32_t
81#   define int32_t _caca_int32_t
82#   undef int64_t
83#   define int64_t _caca_int64_t
84
85typedef unsigned char _caca_uint8_t;
86typedef unsigned short _caca_uint16_t;
87typedef unsigned long int _caca_uint32_t;
88typedef unsigned long long int _caca_uint64_t;
89#   undef uint8_t
90#   define uint8_t _caca_uint8_t
91#   undef uint16_t
92#   define uint16_t _caca_uint16_t
93#   undef uint32_t
94#   define uint32_t _caca_uint32_t
95#   undef uint64_t
96#   define uint64_t _caca_uint64_t
97
98typedef long int _caca_intptr_t;
99typedef unsigned long int _caca_uintptr_t;
100#   undef intptr_t
101#   define intptr_t _caca_intptr_t
102#   undef uintptr_t
103#   define uintptr_t _caca_uintptr_t
104
105typedef int _caca_ssize_t;
106typedef unsigned int _caca_size_t;
107#   undef ssize_t
108#   define ssize_t _caca_ssize_t
109#   undef size_t
110#   define size_t _caca_size_t
111
112#endif
113
114#endif /* __CACA_TYPES_H__ */
Note: See TracBrowser for help on using the repository browser.