Delay inclusion of <stdint.h> when compiling comm2.y

See issue #1 (https://github.com/davidgiven/ack/issues/1).  The file
mach/proto/as/comm2.y goes through cpp twice.  The _include macro,
defined in comm2.y and used in comm0.h, delays the inclusion of system
header files.  The inclusion of <stdint.h> wasn't delayed.  This
caused multiple inclusions of <sys/_types.h> in FreeBSD and
<machine/_types.h> in OpenBSD.

Use _include to delay <stdint.h>.  Also use _include for "arch.h" and
"out.h", because h/out.h includes <stdint.h> and h/arch.h might
include it in the future.

Sort the system includes in comm0.h by moving them up to be with
<stdint.h>.  Must include <stdint.h> before "mach0.c", because
mach/powerpc/as/mach0.c needs it.  Must include "mach0.c" before
checking ASLD.
This commit is contained in:
George Koehler 2017-01-16 22:39:44 -05:00
parent e97116c037
commit 916d270534

View file

@ -8,7 +8,21 @@
* All preprocessor based options/constants/functions
*/
#include <stdint.h>
#ifdef _include
_include <ctype.h>
_include <signal.h>
_include <stdint.h>
_include <stdio.h>
_include <stdlib.h>
_include <string.h>
#else
#include <ctype.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
/* ========== ON/OFF options (use #define in mach0.c) ========== */
@ -80,23 +94,16 @@ separate linker only possible if relocation info produced
/* ========== Machine independent type declarations ========== */
#ifdef _include
_include <stdlib.h>
_include <stdio.h>
_include <string.h>
_include <ctype.h>
_include <signal.h>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <signal.h>
#ifdef ASLD
_include "arch.h"
#endif
_include "out.h"
#else
#ifdef ASLD
#include "arch.h"
#endif
#include "out.h"
#endif
#if DEBUG == 0
#define assert(ex) /* nothing */
@ -265,6 +272,3 @@ typedef struct sect_t sect_t;
#define MACHREL_BWR (0)
#endif
#endif
extern FILE *fopen(); /* some systems don't have this in stdio.h */