diff --git a/src/allocator.h b/src/allocator.h index ab35b4a6..305ab7e9 100644 --- a/src/allocator.h +++ b/src/allocator.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_ALLOCATOR_H -#define KMC_C90_COMPILER_ALLOCATOR_H +#ifndef INCLUDE_GUARD_UUID_369AE7CB_59C4_44F9_827B_3680E4BE4CE3 +#define INCLUDE_GUARD_UUID_369AE7CB_59C4_44F9_827B_3680E4BE4CE3 #include "utility.h" @@ -10,4 +10,4 @@ void* allocate_container(AllocatorRef allocator); void* allocate_element(AllocatorRef allocator, size_t count); void deallocate(AllocatorRef allocator, void* ptr); -#endif /* KMC_C90_COMPILER_ALLOCATOR_H */ +#endif /* INCLUDE_GUARD_UUID_369AE7CB_59C4_44F9_827B_3680E4BE4CE3 */ diff --git a/src/allocator_impl.h b/src/allocator_impl.h index cf76e007..77c440b0 100644 --- a/src/allocator_impl.h +++ b/src/allocator_impl.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_ALLOCATOR_IMPL_H -#define KMC_C90_COMPILER_ALLOCATOR_IMPL_H +#ifndef INCLUDE_GUARD_UUID_733C42B7_9635_4796_A825_357B2A199BA7 +#define INCLUDE_GUARD_UUID_733C42B7_9635_4796_A825_357B2A199BA7 #include "utility.h" @@ -10,4 +10,4 @@ struct Allocator { void (*deallocator_)(void* ptr, void* manager); }; -#endif /* KMC_C90_COMPILER_ALLOCATOR_IMPL_H */ +#endif /* INCLUDE_GUARD_UUID_733C42B7_9635_4796_A825_357B2A199BA7 */ diff --git a/src/ast.h b/src/ast.h index 424a2620..9a1a2cde 100644 --- a/src/ast.h +++ b/src/ast.h @@ -1,8 +1,8 @@ -#ifndef KMC_C90_COMPILER_AST_H -#define KMC_C90_COMPILER_AST_H +#ifndef INCLUDE_GUARD_UUID_1634E4AC_1406_46C3_9240_865975749754 +#define INCLUDE_GUARD_UUID_1634E4AC_1406_46C3_9240_865975749754 enum AstTag { AST_IDENTIFIER }; -#endif /* KMC_C90_COMPILER_AST_H */ +#endif /* INCLUDE_GUARD_UUID_1634E4AC_1406_46C3_9240_865975749754 */ diff --git a/src/memory_pool.h b/src/memory_pool.h index 1c8e220c..3b7f59b2 100644 --- a/src/memory_pool.h +++ b/src/memory_pool.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_MEMORY_POOL_H -#define KMC_C90_COMPILER_MEMORY_POOL_H +#ifndef INCLUDE_GUARD_UUID_CE8F872C_1C85_4BD9_BA55_DCCB9DFCA5FD +#define INCLUDE_GUARD_UUID_CE8F872C_1C85_4BD9_BA55_DCCB9DFCA5FD #include "utility.h" @@ -16,4 +16,4 @@ void memory_pool_dtor(MemoryPoolRef* ppool); /* allocate 'size' memory from pool */ void* palloc_impl(MemoryPoolRef pool, size_t size, size_t alignment); -#endif /* KMC_C90_COMPILER_MEMORY_POOL_H */ +#endif /* INCLUDE_GUARD_UUID_CE8F872C_1C85_4BD9_BA55_DCCB9DFCA5FD */ diff --git a/src/sexpr.h b/src/sexpr.h index 0261cbf4..e5f5de4e 100644 --- a/src/sexpr.h +++ b/src/sexpr.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_SEXPR_H -#define KMC_C90_COMPILER_SEXPR_H +#ifndef INCLUDE_GUARD_UUID_DC32CCE0_A68D_4F17_8621_17C2E13F96F3 +#define INCLUDE_GUARD_UUID_DC32CCE0_A68D_4F17_8621_17C2E13F96F3 #include "ast.h" #include "stdstring.h" @@ -43,4 +43,4 @@ StringRef sexpr_get_symbol(SexprRef sexpr); SexprRef sexpr_make_ast(enum AstTag ast); enum AstTag sexpr_get_ast(SexprRef sexpr); -#endif /* KMC_C90_COMPILER_SEXPR_H */ +#endif /* INCLUDE_GUARD_UUID_DC32CCE0_A68D_4F17_8621_17C2E13F96F3 */ diff --git a/src/sexpr_pool.h b/src/sexpr_pool.h index aaacfdc8..fb80ec68 100644 --- a/src/sexpr_pool.h +++ b/src/sexpr_pool.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_SEXPR_POOL_H -#define KMC_C90_COMPILER_SEXPR_POOL_H +#ifndef INCLUDE_GUARD_UUID_DD55EAEA_2431_4469_A0F8_24CDD9BF0180 +#define INCLUDE_GUARD_UUID_DD55EAEA_2431_4469_A0F8_24CDD9BF0180 #include "allocator.h" #include "memory_pool.h" @@ -10,4 +10,4 @@ void sexpr_finalize_pool(void); AllocatorRef sexpr_symbol_allocator(void); -#endif /* KMC_C90_COMPILER_SEXPR_POOL_H */ +#endif /* INCLUDE_GUARD_UUID_DD55EAEA_2431_4469_A0F8_24CDD9BF0180 */ diff --git a/src/stdstring.h b/src/stdstring.h index 394b96cd..b16e8ce8 100644 --- a/src/stdstring.h +++ b/src/stdstring.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_STDSTRING_H -#define KMC_C90_COMPILER_STDSTRING_H +#ifndef INCLUDE_GUARD_UUID_AC04F0D5_11C0_431B_A82E_4E56DA9456AF +#define INCLUDE_GUARD_UUID_AC04F0D5_11C0_431B_A82E_4E56DA9456AF #include "allocator.h" #include "utility.h" @@ -114,4 +114,4 @@ size_t string_find_first_of(StringRef self, const char* str); /* behavior is undefined if str is NULL */ size_t string_find_first_not_of(StringRef self, const char* str); -#endif /* KMC_C90_COMPILER_STDSTRING_H */ +#endif /* INCLUDE_GUARD_UUID_AC04F0D5_11C0_431B_A82E_4E56DA9456AF */ diff --git a/src/stdstring_impl.h b/src/stdstring_impl.h index 86f3bb52..f0e52d60 100644 --- a/src/stdstring_impl.h +++ b/src/stdstring_impl.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_STDSTRING_IMPL_H -#define KMC_C90_COMPILER_STDSTRING_IMPL_H +#ifndef INCLUDE_GUARD_UUID_5C5CF2B9_E7DB_49BB_94B3_F1C9EEE856D8 +#define INCLUDE_GUARD_UUID_5C5CF2B9_E7DB_49BB_94B3_F1C9EEE856D8 #include "allocator.h" #include "stdstring.h" @@ -11,4 +11,4 @@ struct String { AllocatorRef allocator_; }; -#endif /* KMC_C90_COMPILER_STDSTRING_IMPL_H */ +#endif /* INCLUDE_GUARD_UUID_5C5CF2B9_E7DB_49BB_94B3_F1C9EEE856D8 */ diff --git a/src/use_vector.h b/src/use_vector.h index 94b687d2..6543ae3b 100644 --- a/src/use_vector.h +++ b/src/use_vector.h @@ -1,6 +1,6 @@ -#ifndef KMC_C90_COMPILER_USE_VECTOR_H -#define KMC_C90_COMPILER_USE_VECTOR_H +#ifndef INCLUDE_GUARD_UUID_C9D4FBB0_D15A_468E_8F63_191FED23FD6B +#define INCLUDE_GUARD_UUID_C9D4FBB0_D15A_468E_8F63_191FED23FD6B #include "vector.h" -#endif /* KMC_C90_COMPILER_USE_VECTOR_H */ +#endif /* INCLUDE_GUARD_UUID_C9D4FBB0_D15A_468E_8F63_191FED23FD6B */ diff --git a/src/utility.h b/src/utility.h index 3254de04..205b2c88 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_UTILITY_H -#define KMC_C90_COMPILER_UTILITY_H +#ifndef INCLUDE_GUARD_UUID_F5C18B91_A046_4615_A62F_B79EE7AED603 +#define INCLUDE_GUARD_UUID_F5C18B91_A046_4615_A62F_B79EE7AED603 #include @@ -59,4 +59,4 @@ void memory_move(void* dst, const void* src, size_t size, size_t count); END_EXTERN_C -#endif /* KMC_C90_COMPILER_UTILITY_H */ +#endif /* INCLUDE_GUARD_UUID_F5C18B91_A046_4615_A62F_B79EE7AED603 */ diff --git a/src/vector.h b/src/vector.h index b993665c..590cba33 100644 --- a/src/vector.h +++ b/src/vector.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_VECTOR_H -#define KMC_C90_COMPILER_VECTOR_H +#ifndef INCLUDE_GUARD_UUID_7DB59410_A810_40B5_BB5F_19CB9E822A40 +#define INCLUDE_GUARD_UUID_7DB59410_A810_40B5_BB5F_19CB9E822A40 #include "utility.h" #include "allocator.h" @@ -83,4 +83,4 @@ #include "vector_impl.h" -#endif /* KMC_C90_COMPILER_VECTOR_H */ +#endif /* INCLUDE_GUARD_UUID_7DB59410_A810_40B5_BB5F_19CB9E822A40 */ diff --git a/src/vector_impl.h b/src/vector_impl.h index 887a5c7c..d5d58512 100644 --- a/src/vector_impl.h +++ b/src/vector_impl.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_VECTOR_IMPL_H -#define KMC_C90_COMPILER_VECTOR_IMPL_H +#ifndef INCLUDE_GUARD_UUID_E601D647_8BA3_4262_B950_FE4DD1C72D12 +#define INCLUDE_GUARD_UUID_E601D647_8BA3_4262_B950_FE4DD1C72D12 #include "allocator_impl.h" #include @@ -252,4 +252,4 @@ } \ } \ -#endif /* KMC_C90_COMPILER_VECTOR_IMPL_H */ +#endif /* INCLUDE_GUARD_UUID_E601D647_8BA3_4262_B950_FE4DD1C72D12 */ diff --git a/tests/vector_test/use_vector.h b/tests/vector_test/use_vector.h index bc5c1b4c..a2cb937e 100644 --- a/tests/vector_test/use_vector.h +++ b/tests/vector_test/use_vector.h @@ -1,5 +1,5 @@ -#ifndef KMC_C90_COMPILER_USE_VECTOR_H -#define KMC_C90_COMPILER_USE_VECTOR_H +#ifndef INCLUDE_GUARD_UUID_9515325F_50B2_4EC8_95E3_8B38BFCD1FDE +#define INCLUDE_GUARD_UUID_9515325F_50B2_4EC8_95E3_8B38BFCD1FDE #include "utility.h" #include "vector.h" @@ -8,4 +8,4 @@ BEGIN_EXTERN_C DECLARE_VECTOR(int) END_EXTERN_C -#endif /* KMC_C90_COMPILER_USE_VECTOR_H */ +#endif /* INCLUDE_GUARD_UUID_9515325F_50B2_4EC8_95E3_8B38BFCD1FDE */ diff --git a/uuid-header.sh b/uuid-header.sh new file mode 100755 index 00000000..c145efe1 --- /dev/null +++ b/uuid-header.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +which uuidgen >/dev/null 2>&1 && { + uuidcmd='uuidgen -r' +} || { + uuidcmd='uuid -v4' +} + +for filename in "$@" +do + uuid=$(${uuidcmd} | tr '[a-f-]' '[A-F_]') + macro="INCLUDE_GUARD_UUID_${uuid}" + ifndef="#ifndef ${macro}" + define="#define ${macro}" + endif="#endif /* ${macro} */" + cat <"${filename}" +${ifndef} +${define} + +${endif} +EOF +done