Issue 24811 - Cant compile C code
Summary: Cant compile C code
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 critical
Assignee: No Owner
URL:
Keywords: ImportC
Depends on:
Blocks:
 
Reported: 2024-10-13 20:29 UTC by barbosso
Modified: 2024-10-24 14:26 UTC (History)
1 user (show)

See Also:


Attachments
lib.c (121 bytes, text/x-csrc)
2024-10-13 20:29 UTC, barbosso
Details

Note You need to log in before you can comment on or make changes to this issue.
Description barbosso 2024-10-13 20:29:38 UTC
Created attachment 1919 [details]
lib.c

How to reproduce

//lib.c
typedef float       _Float32;
typedef double      _Float64;
typedef double      _Float32x;
typedef long double _Float64x;
//

clang -c lib.c # compile OK
dmd -c lib.c   # compile ERRORS
lib.c(1): Error: illegal combination of type specifiers
lib.c(2): Error: illegal combination of type specifiers
lib.c(3): Error: illegal combination of type specifiers
lib.c(4): Error: illegal combination of type specifiers
lib.c(4): Error: illegal type combination
Comment 1 barbosso 2024-10-15 10:07:05 UTC
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
|         ^
Comment 2 barbosso 2024-10-16 08:17:57 UTC
SDL3 with callbacks also cant compile
How to reproduce

//SDL3.c
#define __GNUC__ 8
#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main$
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
//

clang -c SDL3.c # compile OK
ldc -c SDL3.c   # compile ERRORS
/usr/include/SDL3/SDL_stdinc.h(4294): Error: undefined identifier `__builtin_mul_overflow`
/usr/include/SDL3/SDL_stdinc.h(4332): Error: undefined identifier `__builtin_add_overflow`
/usr/include/SDL3/SDL_bits.h(79): Error: undefined identifier `__builtin_clz`