Skip to content

Commit

Permalink
fix compilation error with clang++17
Browse files Browse the repository at this point in the history
ocispec/runtime_spec_schema_config_schema.h contains the following code which uses the reserved c++ keyword "class":
typedef struct {
    char *class;
    int32_t priority;
    yajl_val _residual;
    unsigned int priority_present : 1;
}

Thus the code fails to compile with clang++ 17.

Fixes #132 ( #132 )

Signed-off-by: Etienne Cordonnier <[email protected]>
  • Loading branch information
Ecordonnier committed Apr 9, 2024
1 parent 20d3936 commit 86650dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ocispec/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import os
import sys

cxx_reserved_keywords = ["class", "delete", "explicit", "friend", "mutable", "new",
"operator", "private", "protected", "public", "throw", "try", "virtual"]

def append_separator(substr):
'''
Description: append only '_' at last position of subStr
Expand All @@ -45,6 +48,9 @@ def conv_to_c_style(name):
'''
if name is None or name == "":
return ""
# replace C++ reserved keywords (the generated C headers can be included in C++ applications)
if name in cxx_reserved_keywords:
name = '_' + name
name = name.replace('.', '_').replace('-', '_').replace('/', '_')
substr = []
preindex = 0
Expand Down

0 comments on commit 86650dc

Please sign in to comment.