util/format: Make format_table compatible with C++
authorDanylo Piliaiev <dpiliaiev@igalia.com>
Wed, 8 Mar 2023 12:35:22 +0000 (13:35 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 24 Mar 2023 15:49:25 +0000 (15:49 +0000)
Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21931>

src/util/format/u_format_table.py

index 9b7c315..fdab1a2 100644 (file)
@@ -143,8 +143,17 @@ def write_format_table(formats):
 
     write_format_table_header(sys.stdout2)
 
+    print('#ifdef __cplusplus', file=sys.stdout2)
+    print('extern "C" {', file=sys.stdout2)
+    print('#endif', file=sys.stdout2)
+    print(file=sys.stdout2)
+
     u_format_pack.generate(formats)
 
+    print('#ifdef __cplusplus', file=sys.stdout2)
+    print('} /* extern "C" */', file=sys.stdout2)
+    print('#endif', file=sys.stdout2)
+
     def do_channel_array(channels, swizzles):
         print("   {")
         for i in range(4):