Thread overview
Error when compiling with C libs
Oct 13
barbosso
Oct 13
Sergey
Oct 13
barbosso
Oct 13
barbosso
Oct 13
Sergey
Oct 15
barbosso
Oct 15
barbosso
October 13

I can compile tilengine examples with clang, but with ldc I get this error.
Please explain the problem.

ldc -betterC -gcc=clang -release -O3 -L-s -flto=full -Xcc=-I./Tilengine/include -L-L./Tilengine/build -L-l:libTilengine.a -L-lSDL2 -L-lpng -L-lm -L-lz tilengine_main.d

/usr/include/bits/floatn-common.h(214): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(251): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(268): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(285): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(285): Error: illegal type combination

October 13

On Sunday, 13 October 2024 at 13:49:49 UTC, barbosso wrote:

>

I can compile tilengine examples with clang, but with ldc I get this error.

Did you try this bindings? https://github.com/thechampagne/dtilengine

October 13

On Sunday, 13 October 2024 at 14:55:51 UTC, Sergey wrote:

>

On Sunday, 13 October 2024 at 13:49:49 UTC, barbosso wrote:

>

I can compile tilengine examples with clang, but with ldc I get this error.

Did you try this bindings? https://github.com/thechampagne/dtilengine

I want betterC without bindings

October 13

On Sunday, 13 October 2024 at 13:49:49 UTC, barbosso wrote:

>

I can compile tilengine examples with clang, but with ldc I get this error.
Please explain the problem.

ldc -betterC -gcc=clang -release -O3 -L-s -flto=full -Xcc=-I./Tilengine/include -L-L./Tilengine/build -L-l:libTilengine.a -L-lSDL2 -L-lpng -L-lm -L-lz tilengine_main.d

/usr/include/bits/floatn-common.h(214): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(251): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(268): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(285): Error: illegal combination of type specifiers
/usr/include/bits/floatn-common.h(285): Error: illegal type combination

error in line
typedef float _Float32;
clang can compile that line,
but dmd or ldc can not!
This is definatly compiler error!

October 13

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

October 15

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
|

October 15
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
|