blob: 26fb1ccd4eff337f1ccfc0ce0311f3bbb8fe13b7 [file] [log] [blame]
H. Peter Anvinc1494ac2007-04-13 19:58:42 +00001/* ----------------------------------------------------------------------- *
2 *
3 * Copyright 2007 The NASM Authors - All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the license given in the file "License"
7 * distributed in the NASM archive.
8 *
9 * ----------------------------------------------------------------------- */
10
11/*
12 * compiler.h
13 *
14 * Compiler-specific macros for NASM. Feel free to add support for
15 * other compilers in here.
H. Peter Anvinfe501952007-10-02 21:53:51 -070016 *
17 * This header file should be included before any other header.
H. Peter Anvinc1494ac2007-04-13 19:58:42 +000018 */
19
H. Peter Anvinfe501952007-10-02 21:53:51 -070020#ifndef NASM_COMPILER_H
21#define NASM_COMPILER_H 1
H. Peter Anvinc40f89e2007-04-13 20:06:41 +000022
23#ifdef HAVE_CONFIG_H
24# include "config.h"
25#endif
H. Peter Anvinc1494ac2007-04-13 19:58:42 +000026
H. Peter Anvin26573022007-10-18 19:12:39 -070027/* __STRICT_ANSI__ buggers up MinGW, so disable it */
28#ifdef __MINGW32__
29# undef __STRICT_ANSI__
30#endif
31
H. Peter Anvin687b3632007-10-11 12:50:24 -070032/* This is required to get the standard <inttypes.h> macros when compiling
33 with a C++ compiler. This must be defined *before* <inttypes.h> is
34 included, directly or indirectly. */
35#define __STDC_CONSTANT_MACROS 1
36#define __STDC_LIMIT_MACROS 1
37#define __STDC_FORMAT_MACROS 1
38
H. Peter Anvinc1494ac2007-04-13 19:58:42 +000039#ifdef __GNUC__
40# if __GNUC__ >= 4
41# define HAVE_GNUC_4
42# endif
43# if __GNUC__ >= 3
44# define HAVE_GNUC_3
45# endif
46#endif
47
48#ifdef __GNUC__
49# define _unused __attribute__((unused))
50#else
51# define _unused
52#endif
53
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -070054/* Some versions of MSVC have these only with underscores in front */
H. Peter Anvin304b6052007-09-28 10:50:20 -070055#include <stddef.h>
56#include <stdarg.h>
H. Peter Anvinfe501952007-10-02 21:53:51 -070057#include <stdio.h>
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -070058
H. Peter Anvin304b6052007-09-28 10:50:20 -070059#ifndef HAVE_SNPRINTF
60# ifdef HAVE__SNPRINTF
61# define snprintf _snprintf
62# else
63int snprintf(char *, size_t, const char *, ...);
64# endif
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -070065#endif
66
H. Peter Anvin304b6052007-09-28 10:50:20 -070067#ifndef HAVE_VSNPRINTF
68# ifdef HAVE__VSNPRINT
69# define vsnprintf _vsnprintf
70# else
71int vsnprintf(char *, size_t, const char *, va_list);
72# endif
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -070073#endif
74
H. Peter Anvin6867acc2007-10-10 14:58:45 -070075#ifndef __cplusplus /* C++ has false, true, bool as keywords */
76# ifdef HAVE_STDBOOL_H
77# include <stdbool.h>
78# else
79typedef enum { false, true } bool;
80# endif
81#endif
82
H. Peter Anvinfe501952007-10-02 21:53:51 -070083#endif /* NASM_COMPILER_H */