[Coin-discuss] Small patch to fix Clang -Wnon-c-typedef-for-linkage in Clp
Stephan Bergmann
sbergman at redhat.com
Mon Feb 10 04:39:52 EST 2020
[I first tried to file this at
<https://projects.coin-or.org/CoinMP/newticket>, but it says
"TICKET_CREATE privileges are required to perform this operation on
Ticket #None. You don't have the required permissions." Even after I
created an account there.]
Clang 11 trunk since
<https://github.com/llvm/llvm-project/commit/7ae1b4a0ce9c7f269cf3069e41496a78e3f28d49>
"Implement P1766R1: diagnose giving non-C-compatible classes a typedef
name for linkage purposes" gives a warning about certain
typedef struct { ... } name;
in C++. Building CoinMP 1.7.6 as part of building LibreOffice failed with
> In file included from Clp_C_Interface.cpp:192:
> ./Clp_C_Interface.h:15:15: error: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Werror,-Wnon-c-typedef-for-linkage]
> typedef struct {
> ^
> Clp_Solve
> ./Clp_C_Interface.h:15:9: note: type is not C-compatible due to this member declaration
> typedef struct {
> ^~~~~~
> ./Clp_C_Interface.h:17:3: note: type is given name 'Clp_Solve' for linkage purposes by this typedef declaration
> } Clp_Solve;
> ^
(see
<https://gerrit.libreoffice.org/plugins/gitiles/core/+diff/4188c7e2132ec3f1c3e879c179e92ff75c86d24f%5E%21>
"external/coinmp: -Werror,-Wnon-c-typedef-for-linkage"), and I think
CoinMP trunk is also affected. The below patch for Clp should fix it:
> Index: src/Clp_C_Interface.h
> ===================================================================
> --- src/Clp_C_Interface.h (revision 2650)
> +++ src/Clp_C_Interface.h (working copy)
> @@ -21,9 +21,9 @@
> #endif
>
> #if defined(CLP_EXTERN_C)
> -typedef struct {
> +struct Clp_Solve {
> ClpSolve options;
> -} Clp_Solve;
> +};
> #else
> typedef void Clp_Solve;
> #endif
More information about the Coin-discuss
mailing list