Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error with clang++ 17 #132

Closed
Ecordonnier opened this issue Apr 8, 2024 · 3 comments · Fixed by #133
Closed

Compilation error with clang++ 17 #132

Ecordonnier opened this issue Apr 8, 2024 · 3 comments · Fixed by #133

Comments

@Ecordonnier
Copy link
Contributor

Ecordonnier commented Apr 8, 2024

See also the original issue at containers/crun#1446

I am trying to consume libcrun in a c++ program compiled with clang++ 17 by including libcrun/container.h in "extern C" blocks.

#ifdef __cplusplus
extern "C" {
#include <libcrun/container.h>
#endif

#ifdef __cplusplus
}
#endif

The issue is that container.h includes ocispec/runtime_spec_schema_config_schema.h, which 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 compilation fails.

Should this be fixed by replacing the "class" keyword while generating the C header-file in https://github.com/containers/libocispec/blob/main/src/ocispec/headers.py ?

@giuseppe
Copy link
Member

giuseppe commented Apr 8, 2024

would you like to try opening a PR to fix it?

@Ecordonnier
Copy link
Contributor Author

I can do that. I just wanted to confirm my understanding of the needed logic change first. If you agree that I modify the python scripts to replace class with class_, I'll send a PR.

Ecordonnier added a commit to Ecordonnier/libocispec that referenced this issue Apr 9, 2024
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 containers#132 ( containers#132 )

Signed-off-by: Etienne Cordonnier <[email protected]>
@Ecordonnier
Copy link
Contributor Author

See #133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants