containers / crun

A fast and lightweight fully featured OCI runtime and C library for running containers
GNU General Public License v2.0
2.99k stars 304 forks source link

Compilation error with clang++ 17 #1446

Closed Ecordonnier closed 5 months ago

Ecordonnier commented 5 months ago

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.

I am not familiar with the crun repository. 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 commented 5 months ago

yes, I think we need to solve that by changing class with something else. Perhaps adding a underscore at the end?

This must be solved in the libocispec repo though: https://github.com/containers/libocispec

Ecordonnier commented 5 months ago

yes, I think we need to solve that by changing class with something else. Perhaps adding a underscore at the end?

This must be solved in the libocispec repo though: https://github.com/containers/libocispec

OK, I cloned the issue to https://github.com/containers/libocispec/issues/132 . Do you want to close this one?

giuseppe commented 5 months ago

thanks, closing it now