diff --git a/appendices/boilerplate.adoc b/appendices/boilerplate.adoc
index 0b3d297fd..2bd936522 100644
--- a/appendices/boilerplate.adoc
+++ b/appendices/boilerplate.adoc
@@ -310,6 +310,119 @@ current Vulkan headers with their project in this case.
endif::VKSC_VERSION_1_0[]
--
+[open,refpage='VK_USE_64_BIT_FLAGS_ENUMS',desc='Define whether 64 bit constants should be declared using enumerations or static constants',type='defines']
+--
+dname:VK_USE_64_BIT_FLAGS_ENUMS defines whether the default definition 64 bit constants are declared using enumeration with the appropriate underlying type, or as static constants.
+
+dname:VK_USE_64_BIT_FLAGS_ENUMS default definition is set to '1' if the language allows enumerations with explicit underlying type, otherwise '0'.
+
+include::{generated}/api/defines/VK_USE_64_BIT_FLAGS_ENUMS.adoc[]
+
+[NOTE]
+====
+The `{core_header}` header allows the dname:VK_USE_64_BIT_FLAGS_ENUMS
+definition to be overridden by the application.
+====
+
+ifndef::VKSC_VERSION_1_0[]
+[NOTE]
+====
+This macro was introduced starting with the Vulkan 1.4.338 headers, and its
+availability can be checked at compile time by requiring
+`dname:VK_HEADER_VERSION >= 338`.
+
+It is not available if you are using older headers, such as may be shipped
+with an older Vulkan SDK.
+Developers requiring this functionality may wish to include a copy of the
+current Vulkan headers with their project in this case.
+====
+endif::VKSC_VERSION_1_0[]
+--
+
+[open,refpage='VK_BEGIN_ENUMERATION',desc='Begin the definition of an enumeration of constants with a specific underlying type.',type='defines', xrefs='VK_DEFINE_ENUM_VALUE VK_END_ENUMERATION']
+--
+dname:VK_BEGIN_ENUMERATION begins the definition of an enumeration of constants with a specific underlying type.
+
+include::{generated}/api/defines/VK_BEGIN_ENUMERATION.adoc[]
+
+[NOTE]
+====
+The `{core_header}` header allows the dname:VK_BEGIN_ENUMERATION
+definition to be overridden by the application.
+Care must be taken to also override definitions of dname:VK_DEFINE_ENUM_VALUE and dname:VK_END_ENUMERATION accordingly.
+====
+
+ifndef::VKSC_VERSION_1_0[]
+[NOTE]
+====
+This macro was introduced starting with the Vulkan 1.4.338 headers, and its
+availability can be checked at compile time by requiring
+`dname:VK_HEADER_VERSION >= 338`.
+
+It is not available if you are using older headers, such as may be shipped
+with an older Vulkan SDK.
+Developers requiring this functionality may wish to include a copy of the
+current Vulkan headers with their project in this case.
+====
+endif::VKSC_VERSION_1_0[]
+--
+
+[open,refpage='VK_DEFINE_ENUM_VALUE',desc='Define a enumeration value.',type='defines', xrefs='VK_BEGIN_ENUMERATION VK_END_ENUMERATION']
+--
+dname:VK_DEFINE_ENUM_VALUE defines a enumeration value.
+
+include::{generated}/api/defines/VK_DEFINE_ENUM_VALUE.adoc[]
+
+[NOTE]
+====
+The `{core_header}` header allows the dname:VK_DEFINE_ENUM_VALUE
+definition to be overridden by the application.
+Care must be taken to also override definitions of dname:VK_BEGIN_ENUMERATION and dname:VK_END_ENUMERATION accordingly.
+====
+
+ifndef::VKSC_VERSION_1_0[]
+[NOTE]
+====
+This macro was introduced starting with the Vulkan 1.4.338 headers, and its
+availability can be checked at compile time by requiring
+`dname:VK_HEADER_VERSION >= 338`.
+
+It is not available if you are using older headers, such as may be shipped
+with an older Vulkan SDK.
+Developers requiring this functionality may wish to include a copy of the
+current Vulkan headers with their project in this case.
+====
+endif::VKSC_VERSION_1_0[]
+--
+
+[open,refpage='VK_END_ENUMERATION',desc='Close the definition of an enumeration of constants.',type='defines', xrefs='VK_BEGIN_ENUMERATION VK_DEFINE_ENUM_VALUE']
+--
+dname:VK_END_ENUMERATION closes the definition of an enumeration of constants.
+
+include::{generated}/api/defines/VK_END_ENUMERATION.adoc[]
+
+[NOTE]
+====
+The `{core_header}` header allows the dname:VK_END_ENUMERATION
+definition to be overridden by the application.
+Care must be taken to also override definitions of dname:VK_BEGIN_ENUMERATION and dname:VK_DEFINE_ENUM_VALUE accordingly.
+====
+
+ifndef::VKSC_VERSION_1_0[]
+[NOTE]
+====
+This macro was introduced starting with the Vulkan 1.4.338 headers, and its
+availability can be checked at compile time by requiring
+`dname:VK_HEADER_VERSION >= 338`.
+
+It is not available if you are using older headers, such as may be shipped
+with an older Vulkan SDK.
+Developers requiring this functionality may wish to include a copy of the
+current Vulkan headers with their project in this case.
+====
+endif::VKSC_VERSION_1_0[]
+--
+
[[boilerplate-wsi-header]]
== Window System-Specific Header Control (Informative)
diff --git a/registry.adoc b/registry.adoc
index 8c6f399b1..05ec5c5cd 100644
--- a/registry.adoc
+++ b/registry.adoc
@@ -3162,11 +3162,11 @@ For this example, assume we want to define bit flags that can handle up to
[source,c]
--------------------------------------
// Flag bits for VkExampleFlagBits
-typedef VkFlags64 VkExampleFlagBits;
-static const VkExampleFlagBits VK_EXAMPLE_NONE = 0;
-static const VkExampleFlagBits VK_EXAMPLE_FIRST_BIT = 0x00000001;
-static const VkExampleFlagBits VK_EXAMPLE_SECOND_BIT = 0x00000002;
-
+VK_BEGIN_ENUMERATION(VkExampleFlagBits, VkFlags64)
+VK_DEFINE_ENUM_VALUE(VkExampleFlagBits, VK_EXAMPLE_NONE, 0);
+VK_DEFINE_ENUM_VALUE(VkExampleFlagBits, VK_EXAMPLE_FIRST_BIT, 0x00000001);
+VK_DEFINE_ENUM_VALUE(VkExampleFlagBits, VK_EXAMPLE_SECOND_BIT, 0x00000002);
+VK_END_ENUMERATION(VkExampleFlagBits, VkFlags64)
typedef VkFlags64 VkExampleFlags;
--------------------------------------
diff --git a/scripts/generator.py b/scripts/generator.py
index b70510b71..95b675313 100644
--- a/scripts/generator.py
+++ b/scripts/generator.py
@@ -645,12 +645,9 @@ def buildEnumCDecl_BitmaskOrDefine(self, groupinfo, groupName, bitwidth, usedefi
flagTypeName = groupElem.get('name')
# Prefix
- body = f"// Flag bits for {flagTypeName}\n"
-
- if bitwidth == 64:
- body += f"typedef VkFlags64 {flagTypeName};\n";
- else:
- body += f"typedef VkFlags {flagTypeName};\n";
+ body = "// Flag bits for " + flagTypeName + "\n"
+ underlying_type = "VkFlags64" if bitwidth == 64 else "VkFlags"
+ body += f'VK_BEGIN_ENUMERATION({flagTypeName}, {underlying_type})\n'
# Maximum allowable value for a flag (unsigned 64-bit integer)
maxValidValue = 2**(64) - 1
@@ -705,7 +702,7 @@ def buildEnumCDecl_BitmaskOrDefine(self, groupinfo, groupName, bitwidth, usedefi
(numVal, strVal) = self.enumToValue(alias, True, bitwidth, True)
else:
self.logMsg('error', f'No such alias {strVal} for enum {name}')
- decl += f"static const {flagTypeName} {name} = {strVal};\n"
+ decl += f'VK_DEFINE_ENUM_VALUE({flagTypeName}, {name}, {strVal})\n'
if numVal is not None:
body += decl
@@ -719,6 +716,7 @@ def buildEnumCDecl_BitmaskOrDefine(self, groupinfo, groupName, bitwidth, usedefi
body += aliasText
# Postfix
+ body += f'VK_END_ENUMERATION({flagTypeName}, {underlying_type})\n'
return ("bitmask", body)
diff --git a/xml/vk.xml b/xml/vk.xml
index 7d6ec59f8..60980bead 100644
--- a/xml/vk.xml
+++ b/xml/vk.xml
@@ -236,6 +236,39 @@ branch of the member gitlab server.
#endif
#endif
+
+#ifndef VK_USE_64_BIT_FLAGS_ENUMS
+ #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L)) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L))
+ #define VK_USE_64_BIT_FLAGS_ENUMS 1
+ #else
+ #define VK_USE_64_BIT_FLAGS_ENUMS 0
+ #endif
+#endif
+
+#ifndef VK_BEGIN_ENUMERATION
+ #if VK_USE_64_BIT_FLAGS_ENUMS
+ #define VK_BEGIN_ENUMERATION(enum_name, underlying_type) typedef enum enum_name : underlying_type {
+ #else
+ #define VK_BEGIN_ENUMERATION(enum_name, underlying_type) typedef underlying_type enum_name;
+ #endif
+#endif
+
+#ifndef VK_DEFINE_ENUM_VALUE
+ #if VK_USE_64_BIT_FLAGS_ENUMS
+ #define VK_DEFINE_ENUM_VALUE(enum_name, value_name, value) value_name = value,
+ #else
+ #define VK_DEFINE_ENUM_VALUE(enum_name, value_name, value) static const enum_name value_name = value;
+ #endif
+#endif
+
+#ifndef VK_END_ENUMERATION
+ #if VK_USE_64_BIT_FLAGS_ENUMS
+ #define VK_END_ENUMERATION(enum_name, underlying_type) } enum_name;
+ #else
+ #define VK_END_ENUMERATION(enum_name, underlying_type)
+ #endif
+#endif
+
struct ANativeWindow;
struct AHardwareBuffer;
#ifdef __OBJC__
@@ -18153,6 +18186,10 @@ typedef void* MTLSharedEvent_id;
+
+
+
+