summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-28 16:10:05 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-28 16:10:05 -0500
commite6dfff4a2b3a230ff017b637e6f5446fff72dace (patch)
tree9320ccdcc70885eaab2dfc8f337d5cf9a40b47f4
parent184ac5165e70d4fac213a87ae34a312ec7197f3d (diff)
add guards to prevent multiple definitions of the same types
-rw-r--r--mk.sh5
1 files changed, 5 insertions, 0 deletions
diff --git a/mk.sh b/mk.sh
index b2c439a0..642d39ca 100644
--- a/mk.sh
+++ b/mk.sh
@@ -72,6 +72,9 @@ get_declaration () {
;;
TYPE|TYPE_LONG|RECORD|FNTYPE)
+ base=$(basename $1 .c)
+ printf '#ifndef __TYPE_%s_DEFINED__\n#define __TYPE_%s_DEFINED__\n' "$base" "$base"
+
if grep -q '^#if' $1; then
sed -ne '/^#if/,/#endif/p' $1
elif grep -qE '^(typedef|struct|union) .*{' $1; then
@@ -81,6 +84,8 @@ get_declaration () {
else
grep -E '^(typedef|struct|union) ' $1
fi
+
+ printf '#endif\n\n'
;;
EXTERN)