Compile gdbus-codegen generated code (.c) in a cpp-application


#1

I’ve a cpp-application which wants to use dbus. The interface is provided by an xml and translated via gdbus-codegen to c-code but my project is a cpp-code project.

Building the cpp-application with a custom task which calls gdbus-codegen is working so far except, that source.from doesn’t accept .c files and so ignores them totaly.

Is there a way to include c-files in a cpp-applcation. Just renaming doesn’t work as they will bring compile errors when seen as cpp files. So the c-files need to be compiled as c-code too.


#2

Made it work via a cpp-library subproject which is static linked.
and the compilerArgs for this cpp-library set to ["-x", “c”, “-std=gnu11”]

So the subproject is compiled via ccp compiler but with -x c to compile as C code.

And the main project is compiled via cpp compiler with -x c++ and statically linked against that subproject.