Error when compiling with C libs

barbosso barb at your.io
Tue Oct 15 10:13:56 UTC 2024


On Sunday, 13 October 2024 at 21:28:41 UTC, Sergey wrote:
> On Sunday, 13 October 2024 at 20:06:44 UTC, barbosso wrote:
>> error in line
>> ```typedef float _Float32;```
>> clang can compile that line,
>> but dmd or ldc can not!
>> This is definatly compiler error!
>
> It is not an error..
> This is just lack in the implementation.
>
> https://github.com/dlang/dmd/blob/f5fa64a8863e08673cf78a608d28b88e8df832f2/druntime/src/importc.h#L175
>
> Somehow it is working on macOS - aarch64, and not working on 
> Linux 864

I found possible solution
This error occure with inclusion of 
"/usr/include/bits/floatn-common.h" system lib
to prevent error you can define __GNUC__ to be greater than 7
(for example - comment definition)

//lib.c
#define __GNUC__ 8
#include <bits/floatn-common.h>
//

clang -c lib.c # compile OK
dmd -c lib.c   # compile OK with WARNING
lib.c:1:9: warning: '__GNUC__' macro redefined [-Wmacro-redefined]
1 | #define __GNUC__ 8
|         ^
<built-in>:7:9: note: previous definition is here
7 | #define __GNUC__ 4
|


More information about the Digitalmars-d-learn mailing list