@@ -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
@@ -359,11 +350,8 @@ def generate_builtin_bindings(api, output_dir, build_config):
359350 variant_size_source = []
360351 add_header ("variant_size.hpp" , variant_size_source )
361352
362- header_guard = "GODOT_CPP_VARIANT_SIZE_HPP"
363- variant_size_source .append (f"#ifndef { header_guard } " )
364- variant_size_source .append (f"#define { header_guard } " )
353+ variant_size_source .append ("#pragma once" )
365354 variant_size_source .append (f'#define GODOT_CPP_VARIANT_SIZE { builtin_sizes ["Variant" ]} ' )
366- variant_size_source .append (f"#endif // ! { header_guard } " )
367355
368356 variant_size_file .write ("\n " .join (variant_size_source ))
369357
@@ -443,8 +431,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
443431 builtin_header = []
444432 add_header ("builtin_types.hpp" , builtin_header )
445433
446- builtin_header .append ("#ifndef GODOT_CPP_BUILTIN_TYPES_HPP" )
447- builtin_header .append ("#define GODOT_CPP_BUILTIN_TYPES_HPP" )
434+ builtin_header .append ("#pragma once" )
448435
449436 builtin_header .append ("" )
450437
@@ -459,8 +446,6 @@ def generate_builtin_bindings(api, output_dir, build_config):
459446
460447 builtin_header .append ("" )
461448
462- builtin_header .append ("#endif // ! GODOT_CPP_BUILTIN_TYPES_HPP" )
463-
464449 builtin_header_file .write ("\n " .join (builtin_header ))
465450
466451 # Create a header with bindings for builtin types.
@@ -469,8 +454,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
469454 builtin_binds = []
470455 add_header ("builtin_binds.hpp" , builtin_binds )
471456
472- builtin_binds .append ("#ifndef GODOT_CPP_BUILTIN_BINDS_HPP" )
473- builtin_binds .append ("#define GODOT_CPP_BUILTIN_BINDS_HPP" )
457+ builtin_binds .append ("#pragma once" )
474458 builtin_binds .append ("" )
475459 builtin_binds .append ("#include <godot_cpp/variant/builtin_types.hpp>" )
476460 builtin_binds .append ("" )
@@ -482,7 +466,6 @@ def generate_builtin_bindings(api, output_dir, build_config):
482466 builtin_binds .append (f"VARIANT_ENUM_CAST({ builtin_api ['name' ]} ::{ enum_api ['name' ]} );" )
483467
484468 builtin_binds .append ("" )
485- builtin_binds .append ("#endif // ! GODOT_CPP_BUILTIN_BINDS_HPP" )
486469
487470 builtin_binds_file .write ("\n " .join (builtin_binds ))
488471
@@ -498,9 +481,7 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
498481
499482 add_header ("builtin_vararg_methods.hpp" , result )
500483
501- header_guard = "GODOT_CPP_BUILTIN_VARARG_METHODS_HPP"
502- result .append (f"#ifndef { header_guard } " )
503- result .append (f"#define { header_guard } " )
484+ result .append ("#pragma once" )
504485 result .append ("" )
505486 for builtin_api in builtin_classes :
506487 if "methods" not in builtin_api :
@@ -515,8 +496,6 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
515496 )
516497 result .append ("" )
517498
518- result .append (f"#endif // ! { header_guard } " )
519-
520499 return "\n " .join (result )
521500
522501
@@ -526,12 +505,9 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
526505 class_name = builtin_api ["name" ]
527506 snake_class_name = camel_to_snake (class_name ).upper ()
528507
529- header_guard = f"GODOT_CPP_{ snake_class_name } _HPP"
530-
531508 add_header (f"{ snake_class_name .lower ()} .hpp" , result )
532509
533- result .append (f"#ifndef { header_guard } " )
534- result .append (f"#define { header_guard } " )
510+ result .append ("#pragma once" )
535511
536512 result .append ("" )
537513 result .append ("#include <godot_cpp/core/defs.hpp>" )
@@ -960,8 +936,6 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
960936 result .append ("" )
961937 result .append ("} // namespace godot" )
962938
963- result .append ("" )
964- result .append (f"#endif // ! { header_guard } " )
965939 result .append ("" )
966940
967941 return "\n " .join (result )
@@ -1493,9 +1467,7 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
14931467 result = []
14941468 add_header (f"{ snake_struct_name } .hpp" , result )
14951469
1496- header_guard = f"GODOT_CPP_{ snake_struct_name .upper ()} _HPP"
1497- result .append (f"#ifndef { header_guard } " )
1498- result .append (f"#define { header_guard } " )
1470+ result .append ("#pragma once" )
14991471
15001472 used_classes = []
15011473 expanded_format = native_struct ["format" ].replace ("(" , " " ).replace (")" , ";" ).replace ("," , ";" )
@@ -1535,7 +1507,6 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
15351507 result .append ("" )
15361508 result .append ("} // namespace godot" )
15371509 result .append ("" )
1538- result .append (f"#endif // ! { header_guard } " )
15391510
15401511 with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
15411512 header_file .write ("\n " .join (result ))
@@ -1551,11 +1522,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
15511522
15521523 add_header (f"{ snake_class_name .lower ()} .hpp" , result )
15531524
1554- header_guard = f"GODOT_CPP_{ snake_class_name } _HPP"
1555-
1556- result .append (f"#ifndef { header_guard } " )
1557- result .append (f"#define { header_guard } " )
1558-
1525+ result .append ("#pragma once" )
15591526 result .append ("" )
15601527
15611528 if len (fully_used_classes ) > 0 :
@@ -1844,7 +1811,6 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
18441811 result .append ("\t " )
18451812 result .append ("" )
18461813
1847- result .append (f"#endif // ! { header_guard } " )
18481814 result .append ("" )
18491815
18501816 return "\n " .join (result )
@@ -2046,9 +2012,7 @@ def generate_global_constants(api, output_dir):
20462012
20472013 header_filename = include_gen_folder / "global_constants.hpp"
20482014
2049- header_guard = "GODOT_CPP_GLOBAL_CONSTANTS_HPP"
2050- header .append (f"#ifndef { header_guard } " )
2051- header .append (f"#define { header_guard } " )
2015+ header .append ("#pragma once" )
20522016 header .append ("" )
20532017 header .append ("#include <cstdint>" )
20542018 header .append ("" )
@@ -2078,7 +2042,6 @@ def generate_global_constants(api, output_dir):
20782042 header .append ("} // namespace godot" )
20792043
20802044 header .append ("" )
2081- header .append (f"#endif // ! { header_guard } " )
20822045
20832046 with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
20842047 header_file .write ("\n " .join (header ))
@@ -2094,9 +2057,7 @@ def generate_version_header(api, output_dir):
20942057
20952058 header_file_path = include_gen_folder / header_filename
20962059
2097- header_guard = "GODOT_CPP_VERSION_HPP"
2098- header .append (f"#ifndef { header_guard } " )
2099- header .append (f"#define { header_guard } " )
2060+ header .append ("#pragma once" )
21002061 header .append ("" )
21012062
21022063 header .append (f"#define GODOT_VERSION_MAJOR { api ['header' ]['version_major' ]} " )
@@ -2105,8 +2066,6 @@ def generate_version_header(api, output_dir):
21052066 header .append (f"#define GODOT_VERSION_STATUS \" { api ['header' ]['version_status' ]} \" " )
21062067 header .append (f"#define GODOT_VERSION_BUILD \" { api ['header' ]['version_build' ]} \" " )
21072068
2108- header .append ("" )
2109- header .append (f"#endif // { header_guard } " )
21102069 header .append ("" )
21112070
21122071 with header_file_path .open ("w+" , encoding = "utf-8" ) as header_file :
@@ -2127,9 +2086,7 @@ def generate_global_constant_binds(api, output_dir):
21272086
21282087 header_filename = include_gen_folder / "global_constants_binds.hpp"
21292088
2130- header_guard = "GODOT_CPP_GLOBAL_CONSTANTS_BINDS_HPP"
2131- header .append (f"#ifndef { header_guard } " )
2132- header .append (f"#define { header_guard } " )
2089+ header .append ("#pragma once" )
21332090 header .append ("" )
21342091 header .append ("#include <godot_cpp/classes/global_constants.hpp>" )
21352092 header .append ("" )
@@ -2148,8 +2105,6 @@ def generate_global_constant_binds(api, output_dir):
21482105
21492106 header .append ("" )
21502107
2151- header .append (f"#endif // ! { header_guard } " )
2152-
21532108 with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
21542109 header_file .write ("\n " .join (header ))
21552110
@@ -2168,9 +2123,7 @@ def generate_utility_functions(api, output_dir):
21682123
21692124 header_filename = include_gen_folder / "utility_functions.hpp"
21702125
2171- header_guard = "GODOT_CPP_UTILITY_FUNCTIONS_HPP"
2172- header .append (f"#ifndef { header_guard } " )
2173- header .append (f"#define { header_guard } " )
2126+ header .append ("#pragma once" )
21742127 header .append ("" )
21752128 header .append ("#include <godot_cpp/variant/builtin_types.hpp>" )
21762129 header .append ("#include <godot_cpp/variant/variant.hpp>" )
@@ -2209,7 +2162,6 @@ def generate_utility_functions(api, output_dir):
22092162 header .append ("" )
22102163 header .append ("} // namespace godot" )
22112164 header .append ("" )
2212- header .append (f"#endif // ! { header_guard } " )
22132165
22142166 with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
22152167 header_file .write ("\n " .join (header ))
0 commit comments