Bug 22496 – importC: Error: illegal combination of type specifiers

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-11-09T15:10:51Z
Last change time
2022-03-30T13:35:17Z
Keywords
ImportC
Assigned to
No Owner
Creator
Lance Bachmeier

Attachments

IDFilenameSummaryContent-TypeSize
1833fsign_d.cSource file I'm trying to compiletext/x-csrc72121
1834fsign_d2.cSource file without that errortext/x-csrc72147
1835fsign_d2.cCommented file that compilestext/x-csrc72429

Comments

Comment #0 by lance — 2021-11-09T15:10:51Z
Created attachment 1833 Source file I'm trying to compile I ran the original source file through the gcc preprocessor and got the attached fsign_d.c file. It compiles with gcc: gcc -c fsign_d.c but when using dmd: dmd -c fsign_d.c /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(316): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/x86_64-linux-gnu/bits/mathcalls.h(322): Error: illegal combination of type specifiers /usr/include/string.h(43): Error: found `__dest` when expecting `,` /usr/include/string.h(43): Error: found `__src` when expecting `,`
Comment #1 by lance — 2021-11-09T15:36:34Z
Created attachment 1834 Source file without that error
Comment #2 by lance — 2021-11-09T15:38:23Z
If I comment out all single lines that are just __extension__ as in the second uploaded file, that error goes away. Now I get dmd -c fsign_d2.c /usr/include/string.h(43): Error: found `__dest` when expecting `,` /usr/include/string.h(43): Error: found `__src` when expecting `,` /usr/include/string.h(54): Error: found `__dest` when expecting `,` /usr/include/string.h(54): Error: found `__src` when expecting `,` /usr/include/string.h(122): Error: found `__dest` when expecting `,` /usr/include/string.h(122): Error: found `__src` when expecting `,` /usr/include/string.h(125): Error: found `__dest` when expecting `,` /usr/include/string.h(126): Error: found `__src` when expecting `,` /usr/include/string.h(130): Error: found `__dest` when expecting `,` /usr/include/string.h(130): Error: found `__src` when expecting `,` /usr/include/string.h(133): Error: found `__dest` when expecting `,` /usr/include/string.h(133): Error: found `__src` when expecting `,` /usr/include/string.h(147): Error: found `__dest` when expecting `,` /usr/include/string.h(148): Error: found `__src` when expecting `,` /usr/include/string.h(336): Error: found `__s` when expecting `,` /usr/include/string.h(336): Error: found `__delim` when expecting `,` /usr/include/string.h(341): Error: found `__s` when expecting `,` /usr/include/string.h(342): Error: found `__delim` when expecting `,` /usr/include/string.h(343): Error: found `__save_ptr` when expecting `,` /usr/include/string.h(346): Error: found `__s` when expecting `,`
Comment #3 by lance — 2021-11-09T16:06:01Z
Most of the remaining errors are due to dmd choking on restricted pointers. Anything with char *__restrict causes an error.
Comment #4 by lance — 2021-11-09T16:30:43Z
Created attachment 1835 Commented file that compiles
Comment #5 by lance — 2021-11-09T16:35:28Z
I attached a file that compiles with dmd. I had to comment out anything with: - `__extension__` - Restricted pointers `*__restrict` - `_Float128` - `__asm__` And in the source, anything with ISNAN, or in the preprocessed file, - `__builtin_isnan`
Comment #6 by lance — 2021-11-27T15:40:13Z
This is not a bug. Everything was a result of GCC extensions, which are not supported by ImportC, so there's no reason to leave it open.
Comment #7 by carsten.schlote — 2022-03-30T12:25:40Z
Why is this closed? LDC can handle the _restricted keyword, DMD not. I'm currently using ImportC instead of handcrafted bindings, but actually I can't use DMD, when using the GCC -E option.
Comment #8 by carsten.schlote — 2022-03-30T13:02:28Z
For everyone ending up here, due to this bug: Using 'gcc -D_WCHAR_H -E -o output.i input.{c|h}' fixed the problem for me, as it prevents 'wchar.h' to be included, which contained the problematic special keywords of GCC. Of course, this will only work, if you do not need wchar features in your imported C sources.
Comment #9 by lance — 2022-03-30T13:35:17Z
I closed it because it turned out to not be a bug. It's not wrong behavior because GCC extensions are not supported. They're supposed to be working on handling GCC extensions, so if this is still a problem once they release that support, that would really be a different issue anyway.