oxfordcontrol / Clarabel.cpp

Clarabel.cpp: C/C++ interface to the Clarabel Interior-point solver for convex conic optimisation problems.
Apache License 2.0
32 stars 10 forks source link

provide different header for C vs C++ interfaces #28

Closed ghorn closed 5 months ago

ghorn commented 9 months ago

Right now there is one public header: include/Clarabel. This header conditionally includes either the C interface or the C++ interface depending on whether __cplusplus is defined.

My application is C++ but I'm using Clarabel through cvxpygen, which code-generates a convex problem and an interface to various solvers. Cvxpygen uses the C interface to Clarabel.cpp, but when I include the cvxpygen headers it into my C++ application, include/Clarabel picks up that I'm a C++ program and includes the C++ interface. This causes a conflict.

RIght now I have a workaround where I rewrite include/Clarabel to only ever use the C interface, but I think a better solution would be to have a C header include/Clarabel.h and a C++ header include/Clarabel.

ghorn commented 9 months ago

Would you accept a PR for this? I would split the header into include/Clarabel (C++) and include/Clarabel.h (C).

ghorn commented 9 months ago

I just opened a PR. It passes unit tests. Happy to implement a different solution if you prefer.

ghorn commented 7 months ago

Bump, in case you missed this

goulart-paul commented 5 months ago

Apologies - was waiting to do it all together with v0.7.0, which probably wasn't necessary. Thank you for doing this.

ghorn commented 5 months ago

Thank you!