[Coin-discuss] Small patch to fix Clang -Wnon-c-typedef-for-linkage in Clp

Stefan Vigerske svigerske at gams.com
Mon Feb 10 08:51:41 EST 2020


Hi,

On 2/10/20 10:39 AM, Stephan Bergmann wrote:
> [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.]

The project has partly moved to GitHub and issue tracking is now on 
GitHub only (https://github.com/coin-or/CoinMP/issues).

> 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


I committed something similar to Clp's master/trunk, which should have 
the same effect:
https://github.com/coin-or/Clp/commit/868c96f2f29ca0c6962ab794a62f928f1f3698dd

Thank you,
Stefan

> 
> _______________________________________________
> Coin-discuss mailing list
> Coin-discuss at list.coin-or.org
> https://list.coin-or.org/mailman/listinfo/coin-discuss



More information about the Coin-discuss mailing list