Bug 24187 – ImportC: _Float32 not defined

Status
RESOLVED
Resolution
WORKSFORME
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-10-13T17:43:14Z
Last change time
2023-11-12T19:01:09Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
mw

Attachments

IDFilenameSummaryContent-TypeSize
1895s7.i.gzs7.i.gz attached. dmd s7.i shows the same error.application/octet-stream689358
1897s2.ireduced to 2 lines: s2.itext/plain410

Comments

Comment #0 by mingwu — 2023-10-13T17:43:14Z
$ cat /etc/issue Ubuntu 22.04 LTS \n \l $ dmd --version DMD64 D Compiler v2.105.0 I try to build s7 with ImportC from here: https://ccrma.stanford.edu/software/s7/s7.tar.gz $ dmd s7.c /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(55): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(55): Error: missing comma or semicolon after declaration of `_Float32`, found `cacosf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(55): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(55): Error: missing comma or semicolon after declaration of `_Float32`, found `__cacosf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(57): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(57): Error: missing comma or semicolon after declaration of `_Float32`, found `casinf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(57): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(57): Error: missing comma or semicolon after declaration of `_Float32`, found `__casinf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(59): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(59): Error: missing comma or semicolon after declaration of `_Float32`, found `catanf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(59): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(59): Error: missing comma or semicolon after declaration of `_Float32`, found `__catanf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(62): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(62): Error: missing comma or semicolon after declaration of `_Float32`, found `ccosf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(62): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(62): Error: missing comma or semicolon after declaration of `_Float32`, found `__ccosf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(64): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(64): Error: missing comma or semicolon after declaration of `_Float32`, found `csinf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(64): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(64): Error: missing comma or semicolon after declaration of `_Float32`, found `__csinf32` instead
Comment #1 by mingwu — 2023-10-14T17:37:54Z
Steps to reproduce: $ tar xzf s7.tar.gz $ cd s7 $ dmd s7.c BTW, LDC2 has the same error, because it share the same front end with DMD.
Comment #2 by bugzilla — 2023-10-18T07:06:54Z
My Linux machine apparently has a different cmathcalls.h file than yours. If you could isolate the source code that causes this problem, that would be most helpful.
Comment #3 by mingwu — 2023-10-18T22:29:58Z
I can upload the generated s7.i on my machine, do you think it will helpful?
Comment #4 by mingwu — 2023-10-18T22:34:38Z
Created attachment 1895 s7.i.gz attached. dmd s7.i shows the same error. s7.i.gz attached. dmd s7.i shows the same error.
Comment #5 by bugzilla — 2023-10-29T08:12:04Z
Thank you. What would be even more helpful would be to cut it down to just what produces the error!
Comment #6 by mingwu — 2023-10-30T05:16:31Z
Haha, I made it: 2 lines! $ cat s2.i extern _Complex _Float32 cacosf32 (_Complex _Float32 __z) __attribute__ ((__nothrow__ , __leaf__)); extern _Complex _Float32 __cacosf32 (_Complex _Float32 __z) __attribute__ ((__nothrow__ , __leaf__)); extern _Complex _Float32x cacosf32x (_Complex _Float32x __z) __attribute__ ((__nothrow__ , __leaf__)); extern _Complex _Float32x __cacosf32x (_Complex _Float32x __z) __attribute__ ((__nothrow__ , __leaf__)); $ gcc -c s2.i # ok $ dmd s2.i s2.i(1): Error: illegal type combination s2.i(1): Error: missing comma or semicolon after declaration of `_Float32`, found `cacosf32` instead s2.i(1): Error: illegal type combination s2.i(1): Error: missing comma or semicolon after declaration of `_Float32`, found `__cacosf32` instead s2.i(2): Error: illegal type combination s2.i(2): Error: missing comma or semicolon after declaration of `_Float32x`, found `cacosf32x` instead s2.i(2): Error: illegal type combination s2.i(2): Error: missing comma or semicolon after declaration of `_Float32x`, found `__cacosf32x` instead I will attach s2.i. But if you fix s2.i, pls also try if the fix works for s7.i.gz.
Comment #7 by mingwu — 2023-10-30T05:18:00Z
Created attachment 1897 reduced to 2 lines: s2.i
Comment #8 by bugzilla — 2023-10-30T05:50:49Z
The two lines: extern _Complex _Float32 cacosf32 (_Complex _Float32 __z) __attribute__ ((__nothrow__ , __leaf__)); extern _Complex _Float32 __cacosf32 (_Complex _Float32 __z) __attribute__ ((__nothrow__ , __leaf__)); extern _Complex _Float32x cacosf32x (_Complex _Float32x __z) __attribute__ ((__nothrow__ , __leaf__)); extern _Complex _Float32x __cacosf32x (_Complex _Float32x __z) __attribute__ ((__nothrow__ , __leaf__)); Thanks, this reproduces the problem.
Comment #9 by bugzilla — 2023-10-30T05:54:53Z
It compiles without error if `Float32` is replaced with `float`.
Comment #10 by dlang-bot — 2023-10-30T06:04:55Z
@WalterBright created dlang/dmd pull request #15751 "fix Issue 24187 - ImportC: _Float32 not defined" fixing this issue: - fix Issue 24187 - ImportC: _Float32 not defined https://github.com/dlang/dmd/pull/15751
Comment #11 by mingwu — 2023-10-30T07:07:45Z
Thanks for the quick fix. C has So many defines ...
Comment #12 by dlang-bot — 2023-10-30T09:29:00Z
dlang/dmd pull request #15751 "fix Issue 24187 - ImportC: _Float32 not defined" was merged into master: - e0a033dfae29c6ad6f54af804d845e5793630658 by Walter Bright: fix Issue 24187 - ImportC: _Float32 not defined https://github.com/dlang/dmd/pull/15751
Comment #13 by mingwu — 2023-11-04T19:57:58Z
Is this issue really fixed? I just tried the latest dmd which suppose to have the fix, but it still cannot compile s2.i and s7.i: $ dmd --version DMD64 D Compiler v2.106.0-beta.1 $ $ dmd s2.i s2.i(1): Error: illegal type combination s2.i(1): Error: missing comma or semicolon after declaration of `_Float32`, found `cacosf32` instead s2.i(1): Error: illegal type combination s2.i(1): Error: missing comma or semicolon after declaration of `_Float32`, found `__cacosf32` instead s2.i(2): Error: illegal type combination s2.i(2): Error: missing comma or semicolon after declaration of `_Float32x`, found `cacosf32x` instead s2.i(2): Error: illegal type combination s2.i(2): Error: missing comma or semicolon after declaration of `_Float32x`, found `__cacosf32x` instead $ dmd s7.i /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(55): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(55): Error: missing comma or semicolon after declaration of `_Float32`, found `cacosf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(55): Error: illegal type combination /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(55): Error: missing comma or semicolon after declaration of `_Float32`, found `__cacosf32` instead /usr/include/x86_64-linux-gnu/bits/cmathcalls.h(57): Error: illegal type combination ...
Comment #14 by bugzilla — 2023-11-06T18:28:10Z
It's fixed in the reduced sample you provided. Can you try that with the compiler?
Comment #15 by mingwu — 2023-11-06T19:27:42Z
I tried already, you can see from my previous post. $ dmd --version DMD64 D Compiler v2.106.0-beta.1
Comment #16 by bugzilla — 2023-11-11T04:40:03Z
Rename s2.i to s2.c and it will compile. The reason is that .c files are first sent through the C preprocessor, which automatically #include's importc.h, which contains the macro for _Float32.
Comment #17 by mingwu — 2023-11-12T19:01:09Z
Thanks, it worked. Now if we can get this issue fixed, then we can compile s7.c https://issues.dlang.org/show_bug.cgi?id=24228