@@ -51,11 +51,7 @@ def generate_mod_version(argcount, const=False, returns=False):
5151def generate_wrappers (target ):
5252 max_versions = 12
5353
54- txt = """
55- #ifndef GDEXTENSION_WRAPPERS_GEN_H
56- #define GDEXTENSION_WRAPPERS_GEN_H
57-
58- """
54+ txt = "#pragma once"
5955
6056 for i in range (max_versions + 1 ):
6157 txt += "\n /* Module Wrapper " + str (i ) + " Arguments */\n "
@@ -64,8 +60,6 @@ def generate_wrappers(target):
6460 txt += generate_mod_version (i , True , False )
6561 txt += generate_mod_version (i , True , True )
6662
67- txt += "\n #endif\n "
68-
6963 with open (target , "w" , encoding = "utf-8" ) as f :
7064 f .write (txt )
7165
@@ -187,8 +181,7 @@ def generate_virtuals(target):
187181 max_versions = 12
188182
189183 txt = """/* THIS FILE IS GENERATED DO NOT EDIT */
190- #ifndef GDEXTENSION_GDVIRTUAL_GEN_H
191- #define GDEXTENSION_GDVIRTUAL_GEN_H
184+ #pragma once
192185
193186"""
194187
@@ -203,8 +196,6 @@ def generate_virtuals(target):
203196 txt += generate_virtual_version (i , True , False , True )
204197 txt += generate_virtual_version (i , True , True , True )
205198
206- txt += "#endif // GDEXTENSION_GDVIRTUAL_GEN_H\n "
207-
208199 with open (target , "w" , encoding = "utf-8" ) as f :
209200 f .write (txt )
210201
@@ -364,11 +355,8 @@ def generate_builtin_bindings(api, output_dir, build_config):
364355 variant_size_source = []
365356 add_header ("variant_size.hpp" , variant_size_source )
366357
367- header_guard = "GODOT_CPP_VARIANT_SIZE_HPP"
368- variant_size_source .append (f"#ifndef { header_guard } " )
369- variant_size_source .append (f"#define { header_guard } " )
358+ variant_size_source .append ("#pragma once" )
370359 variant_size_source .append (f'#define GODOT_CPP_VARIANT_SIZE { builtin_sizes ["Variant" ]} ' )
371- variant_size_source .append (f"#endif // ! { header_guard } " )
372360
373361 variant_size_file .write ("\n " .join (variant_size_source ))
374362
@@ -448,8 +436,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
448436 builtin_header = []
449437 add_header ("builtin_types.hpp" , builtin_header )
450438
451- builtin_header .append ("#ifndef GODOT_CPP_BUILTIN_TYPES_HPP" )
452- builtin_header .append ("#define GODOT_CPP_BUILTIN_TYPES_HPP" )
439+ builtin_header .append ("#pragma once" )
453440
454441 builtin_header .append ("" )
455442
@@ -464,8 +451,6 @@ def generate_builtin_bindings(api, output_dir, build_config):
464451
465452 builtin_header .append ("" )
466453
467- builtin_header .append ("#endif // ! GODOT_CPP_BUILTIN_TYPES_HPP" )
468-
469454 builtin_header_file .write ("\n " .join (builtin_header ))
470455
471456 # Create a header with bindings for builtin types.
@@ -474,8 +459,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
474459 builtin_binds = []
475460 add_header ("builtin_binds.hpp" , builtin_binds )
476461
477- builtin_binds .append ("#ifndef GODOT_CPP_BUILTIN_BINDS_HPP" )
478- builtin_binds .append ("#define GODOT_CPP_BUILTIN_BINDS_HPP" )
462+ builtin_binds .append ("#pragma once" )
479463 builtin_binds .append ("" )
480464 builtin_binds .append ("#include <godot_cpp/variant/builtin_types.hpp>" )
481465 builtin_binds .append ("" )
@@ -487,7 +471,6 @@ def generate_builtin_bindings(api, output_dir, build_config):
487471 builtin_binds .append (f"VARIANT_ENUM_CAST({ builtin_api ['name' ]} ::{ enum_api ['name' ]} );" )
488472
489473 builtin_binds .append ("" )
490- builtin_binds .append ("#endif // ! GODOT_CPP_BUILTIN_BINDS_HPP" )
491474
492475 builtin_binds_file .write ("\n " .join (builtin_binds ))
493476
@@ -503,9 +486,7 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
503486
504487 add_header ("builtin_vararg_methods.hpp" , result )
505488
506- header_guard = "GODOT_CPP_BUILTIN_VARARG_METHODS_HPP"
507- result .append (f"#ifndef { header_guard } " )
508- result .append (f"#define { header_guard } " )
489+ result .append ("#pragma once" )
509490 result .append ("" )
510491 for builtin_api in builtin_classes :
511492 if "methods" not in builtin_api :
@@ -520,8 +501,6 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
520501 )
521502 result .append ("" )
522503
523- result .append (f"#endif // ! { header_guard } " )
524-
525504 return "\n " .join (result )
526505
527506
@@ -531,12 +510,9 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
531510 class_name = builtin_api ["name" ]
532511 snake_class_name = camel_to_snake (class_name ).upper ()
533512
534- header_guard = f"GODOT_CPP_{ snake_class_name } _HPP"
535-
536513 add_header (f"{ snake_class_name .lower ()} .hpp" , result )
537514
538- result .append (f"#ifndef { header_guard } " )
539- result .append (f"#define { header_guard } " )
515+ result .append ("#pragma once" )
540516
541517 result .append ("" )
542518 result .append ("#include <godot_cpp/core/defs.hpp>" )
@@ -965,8 +941,6 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
965941 result .append ("" )
966942 result .append ("} // namespace godot" )
967943
968- result .append ("" )
969- result .append (f"#endif // ! { header_guard } " )
970944 result .append ("" )
971945
972946 return "\n " .join (result )
@@ -1498,9 +1472,7 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
14981472 result = []
14991473 add_header (f"{ snake_struct_name } .hpp" , result )
15001474
1501- header_guard = f"GODOT_CPP_{ snake_struct_name .upper ()} _HPP"
1502- result .append (f"#ifndef { header_guard } " )
1503- result .append (f"#define { header_guard } " )
1475+ result .append ("#pragma once" )
15041476
15051477 used_classes = []
15061478 expanded_format = native_struct ["format" ].replace ("(" , " " ).replace (")" , ";" ).replace ("," , ";" )
@@ -1540,7 +1512,6 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
15401512 result .append ("" )
15411513 result .append ("} // namespace godot" )
15421514 result .append ("" )
1543- result .append (f"#endif // ! { header_guard } " )
15441515
15451516 with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
15461517 header_file .write ("\n " .join (result ))
@@ -1556,11 +1527,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
15561527
15571528 add_header (f"{ snake_class_name .lower ()} .hpp" , result )
15581529
1559- header_guard = f"GODOT_CPP_{ snake_class_name } _HPP"
1560-
1561- result .append (f"#ifndef { header_guard } " )
1562- result .append (f"#define { header_guard } " )
1563-
1530+ result .append ("#pragma once" )
15641531 result .append ("" )
15651532
15661533 if len (fully_used_classes ) > 0 :
@@ -1849,7 +1816,6 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
18491816 result .append ("\t " )
18501817 result .append ("" )
18511818
1852- result .append (f"#endif // ! { header_guard } " )
18531819 result .append ("" )
18541820
18551821 return "\n " .join (result )
@@ -2051,9 +2017,7 @@ def generate_global_constants(api, output_dir):
20512017
20522018 header_filename = include_gen_folder / "global_constants.hpp"
20532019
2054- header_guard = "GODOT_CPP_GLOBAL_CONSTANTS_HPP"
2055- header .append (f"#ifndef { header_guard } " )
2056- header .append (f"#define { header_guard } " )
2020+ header .append ("#pragma once" )
20572021 header .append ("" )
20582022 header .append ("#include <cstdint>" )
20592023 header .append ("" )
@@ -2083,7 +2047,6 @@ def generate_global_constants(api, output_dir):
20832047 header .append ("} // namespace godot" )
20842048
20852049 header .append ("" )
2086- header .append (f"#endif // ! { header_guard } " )
20872050
20882051 with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
20892052 header_file .write ("\n " .join (header ))
@@ -2099,9 +2062,7 @@ def generate_version_header(api, output_dir):
20992062
21002063 header_file_path = include_gen_folder / header_filename
21012064
2102- header_guard = "GODOT_CPP_VERSION_HPP"
2103- header .append (f"#ifndef { header_guard } " )
2104- header .append (f"#define { header_guard } " )
2065+ header .append ("#pragma once" )
21052066 header .append ("" )
21062067
21072068 header .append (f"#define GODOT_VERSION_MAJOR { api ['header' ]['version_major' ]} " )
@@ -2110,8 +2071,6 @@ def generate_version_header(api, output_dir):
21102071 header .append (f"#define GODOT_VERSION_STATUS \" { api ['header' ]['version_status' ]} \" " )
21112072 header .append (f"#define GODOT_VERSION_BUILD \" { api ['header' ]['version_build' ]} \" " )
21122073
2113- header .append ("" )
2114- header .append (f"#endif // { header_guard } " )
21152074 header .append ("" )
21162075
21172076 with header_file_path .open ("w+" , encoding = "utf-8" ) as header_file :
@@ -2132,9 +2091,7 @@ def generate_global_constant_binds(api, output_dir):
21322091
21332092 header_filename = include_gen_folder / "global_constants_binds.hpp"
21342093
2135- header_guard = "GODOT_CPP_GLOBAL_CONSTANTS_BINDS_HPP"
2136- header .append (f"#ifndef { header_guard } " )
2137- header .append (f"#define { header_guard } " )
2094+ header .append ("#pragma once" )
21382095 header .append ("" )
21392096 header .append ("#include <godot_cpp/classes/global_constants.hpp>" )
21402097 header .append ("" )
@@ -2153,8 +2110,6 @@ def generate_global_constant_binds(api, output_dir):
21532110
21542111 header .append ("" )
21552112
2156- header .append (f"#endif // ! { header_guard } " )
2157-
21582113 with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
21592114 header_file .write ("\n " .join (header ))
21602115
@@ -2173,9 +2128,7 @@ def generate_utility_functions(api, output_dir):
21732128
21742129 header_filename = include_gen_folder / "utility_functions.hpp"
21752130
2176- header_guard = "GODOT_CPP_UTILITY_FUNCTIONS_HPP"
2177- header .append (f"#ifndef { header_guard } " )
2178- header .append (f"#define { header_guard } " )
2131+ header .append ("#pragma once" )
21792132 header .append ("" )
21802133 header .append ("#include <godot_cpp/variant/builtin_types.hpp>" )
21812134 header .append ("#include <godot_cpp/variant/variant.hpp>" )
@@ -2214,7 +2167,6 @@ def generate_utility_functions(api, output_dir):
22142167 header .append ("" )
22152168 header .append ("} // namespace godot" )
22162169 header .append ("" )
2217- header .append (f"#endif // ! { header_guard } " )
22182170
22192171 with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
22202172 header_file .write ("\n " .join (header ))
0 commit comments