How do you get S if your program is written in C? I assume that the most accurate description is that your program is written in combination with C and C ++, and you want to access some members of the C ++ structure in part C.
Solution 1: change your C part so that it is in a common subset of C and C ++, compile the result as C ++, and now you can gradually use any C ++ function you want. This is what has been done in the past. The most famous of the latter is GCC.
Solution 2: provide the āCā front end for S and use it in your C part.
#ifdef __cplusplus extern "C" { #endif struct S; int getA(S*); int getB(S*); #ifdef __cplusplus } #endif
The part that provides the implementation of getA and getB must be compiled as C ++, but will be called from C.
source share