From 19310d2521ddf88e896ecf9c4ee5a1fe7fe9aab8 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Tue, 22 Nov 2016 11:13:14 -0500 Subject: [PATCH] Make possible to #include . This header declares functions in libobject. Our programs never included object.h, but called functions in libobject without declaring them. So, our build system never put object.h in the include path; any #include would fail to find the header. With this commit, a program may #include if it has modules/src/object+lib in its deps. Declare structs in object.h so we can use them in prototypes without gcc warning, "'struct whatever' declared inside parameter list". Remove inclusion of ansi.h from object.h. Programs would need to depend on modules+headers to get ansi.h in the include path. --- modules/src/object/build.lua | 1 + modules/src/object/object.h | 72 +++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/modules/src/object/build.lua b/modules/src/object/build.lua index c30c7e54a..6a8bea04e 100644 --- a/modules/src/object/build.lua +++ b/modules/src/object/build.lua @@ -1,6 +1,7 @@ clibrary { name = "lib", srcs = { "./*.c" }, + hdrs = { "./object.h" }, deps = { "modules+headers", "h+local", diff --git a/modules/src/object/object.h b/modules/src/object/object.h index 68a5ea99f..d6c218a2a 100644 --- a/modules/src/object/object.h +++ b/modules/src/object/object.h @@ -4,42 +4,46 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include - #ifndef __OBJECT_INCLUDED__ #define __OBJECT_INCLUDED__ -_PROTOTYPE(int wr_open, (char *f)); -_PROTOTYPE(void wr_close, (void)); -_PROTOTYPE(void wr_ohead, (struct outhead *h)); -_PROTOTYPE(void wr_sect, (struct outsect *s, unsigned int c)); -_PROTOTYPE(void wr_outsect, (int sectno)); -_PROTOTYPE(void wr_emit, (char *b, long c)); -_PROTOTYPE(void wr_putc, (int c)); -_PROTOTYPE(void wr_relo, (struct outrelo *r, unsigned int c)); -_PROTOTYPE(void wr_name, (struct outname *n, unsigned int c)); -_PROTOTYPE(void wr_string, (char *s, long c)); -_PROTOTYPE(void wr_arhdr, (int fd, struct ar_hdr *a)); -_PROTOTYPE(void wr_ranlib, (int fd, struct ranlib *r, long cnt)); -_PROTOTYPE(void wr_int2, (int fd, int i)); -_PROTOTYPE(void wr_long, (int fd, long l)); -_PROTOTYPE(void wr_bytes, (int fd, char *buf, long l)); -_PROTOTYPE(int rd_open, (char *f)); -_PROTOTYPE(int rd_fdopen, (int f)); -_PROTOTYPE(void rd_close, (void)); -_PROTOTYPE(void rd_ohead, (struct outhead *h)); -_PROTOTYPE(void rd_sect, (struct outsect *s, unsigned int c)); -_PROTOTYPE(void rd_outsect, (int sectno)); -_PROTOTYPE(void rd_emit, (char *b, long c)); -_PROTOTYPE(void rd_relo, (struct outrelo *r, unsigned int c)); -_PROTOTYPE(void rd_rew_relo, (struct outhead *head)); -_PROTOTYPE(void rd_name, (struct outname *n, unsigned int c)); -_PROTOTYPE(void rd_string, (char *s, long c)); -_PROTOTYPE(int rd_arhdr, (int fd, struct ar_hdr *a)); -_PROTOTYPE(void rd_ranlib, (int fd, struct ranlib *r, long cnt)); -_PROTOTYPE(int rd_int2, (int fd)); -_PROTOTYPE(long rd_long, (int fd)); -_PROTOTYPE(void rd_bytes, (int fd, char *buf, long l)); -_PROTOTYPE(int rd_fd, (void)); +struct ar_hdr; +struct outhead; +struct outrelo; +struct outsect; +struct ranlib; + +int wr_open(char *f); +void wr_close(void); +void wr_ohead(struct outhead *h); +void wr_sect(struct outsect *s, unsigned int c); +void wr_outsect(int sectno); +void wr_emit(char *b, long c); +void wr_putc(int c); +void wr_relo(struct outrelo *r, unsigned int c); +void wr_name(struct outname *n, unsigned int c); +void wr_string(char *s, long c); +void wr_arhdr(int fd, struct ar_hdr *a); +void wr_ranlib(int fd, struct ranlib *r, long cnt); +void wr_int2(int fd, int i); +void wr_long(int fd, long l); +void wr_bytes(int fd, char *buf, long l); +int rd_open(char *f); +int rd_fdopen(int f); +void rd_close(void); +void rd_ohead(struct outhead *h); +void rd_sect(struct outsect *s, unsigned int c); +void rd_outsect(int sectno); +void rd_emit(char *b, long c); +void rd_relo(struct outrelo *r, unsigned int c); +void rd_rew_relo(struct outhead *head); +void rd_name(struct outname *n, unsigned int c); +void rd_string(char *s, long c); +int rd_arhdr(int fd, struct ar_hdr *a); +void rd_ranlib(int fd, struct ranlib *r, long cnt); +int rd_int2(int fd); +long rd_long(int fd); +void rd_bytes(int fd, char *buf, long l); +int rd_fd(void); #endif /* __OBJECT_INCLUDED__ */