Bug 23690 – compilable/cimports2.i:1:1: error: unknown type name '__import'

Status
RESOLVED
Resolution
WONTFIX
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2023-02-12T14:41:00Z
Last change time
2023-02-15T21:37:00Z
Keywords
accepts-invalid, ImportC
Assigned to
No Owner
Creator
Iain Buclaw
Depends on
23689
See also
https://issues.dlang.org/show_bug.cgi?id=23689

Comments

Comment #0 by ibuclaw — 2023-02-12T14:41:00Z
When compiling the test with `gcc -std=c11 -fsyntax-only` compilable/cimports2.i:1:1: error: unknown type name ‘__import’ 1 | __import imports.cimports2a; | ^~~~~~~~ compilable/cimports2.i:1:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token 1 | __import imports.cimports2a; | ^ compilable/cimports2.i:2:1: error: unknown type name ‘__import’ 2 | __import imports.cimports2b; | ^~~~~~~~ compilable/cimports2.i:2:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token 2 | __import imports.cimports2b; | ^ compilable/cimports2.i:4:11: error: ‘xx’ undeclared here (not in a function) 4 | int *p = &xx; | ^~
Comment #1 by ibuclaw — 2023-02-12T14:42:29Z
Original source content: ``` __import imports.cimports2a; __import imports.cimports2b; int *p = &xx; ```
Comment #2 by ibuclaw — 2023-02-12T14:52:55Z
Another failing test in compilable/cimport.c compilable/cimport.c:3:1: error: unknown type name ‘__import’ 3 | __import core.stdc.stdarg; | ^~~~~~~~ compilable/cimport.c:3:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token 3 | __import core.stdc.stdarg; | ^ compilable/cimport.c:4:1: error: unknown type name ‘__import’ 4 | __import imports.impcimport; | ^~~~~~~~ compilable/cimport.c:4:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token 4 | __import imports.impcimport; | ^ compilable/cimport.c: In function ‘foo’: compilable/cimport.c:8:5: error: unknown type name ‘va_list’ 8 | va_list x; | ^~~~~~~ compilable/cimport.c:1:1: note: ‘va_list’ is defined in header ‘<stdarg.h>’; did you forget to ‘#include <stdarg.h>’? +++ |+#include <stdarg.h> 1 | // https://issues.dlang.org/show_bug.cgi?id=22666 compilable/cimport.c:9:16: error: ‘A’ undeclared (first use in this function) 9 | return 1 + A; | ^ compilable/cimport.c:9:16: note: each undeclared identifier is reported only once for each function it appears in Original test content: ``` // https://issues.dlang.org/show_bug.cgi?id=22666 __import core.stdc.stdarg; __import imports.impcimport; int foo() { va_list x; return 1 + A; } ```
Comment #3 by ibuclaw — 2023-02-15T21:37:00Z
This is an ImportC extension to the C language, and has been documented on the dlang.org pages here. https://dlang.org/spec/importc.html#__import