From 6ad9d41d435c778a46357da81eb8ada27a8f5854 Mon Sep 17 00:00:00 2001 From: aheifetz Date: Fri, 7 Apr 2017 02:52:32 -0400 Subject: [PATCH] Added include guards to generated header file --- check.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/check.py b/check.py index 7b36680..618bf22 100755 --- a/check.py +++ b/check.py @@ -592,6 +592,9 @@ def rh(text): if errors.startswith('No errors in'): message_types = parse_spec_file(spec_file) with open(output_file, 'w') as f: + clean_output_file = re.sub('[^A-Za-z0-9_]+', '_', output_file).upper() + f.write('#ifndef ____' + clean_output_file + '\n') + f.write('#define ____' + clean_output_file + '\n\n') for message_id, message_type in message_types.items(): message_name = rh(message_type.name) f.write('#define ' + message_name + '__id ' + str(message_type.can_id) + '\n') @@ -615,6 +618,7 @@ def rh(text): f.write('\n') + f.write('#endif // ____' + clean_output_file + '\n') finally: spec_file.close()