Bug 22251 – ImportC: Array -> Pointer implicit conversion does not work
Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-08-30T03:17:58Z
Last change time
2021-09-26T09:34:16Z
Keywords
ImportC
Assigned to
No Owner
Creator
mhh
Comments
Comment #0 by maxhaton — 2021-08-30T03:17:58Z
In C a value of array type can be implicitly converted to a pointer to it's first element. This does not work in ImportC.
Example:
---
char* strcpy(char* destination, const char* source);
int puts(char*);
int main()
{
char staticArray[256];
strcpy(staticArray, "mhh is allergic to pollen");
puts(staticArray);
}
---
yields:
static_array.c(8): Error: function `static_array.strcpy(char* destination, const(char*) source)` is not callable using argument types `(char[256], char*)`
static_array.c(8): cannot pass argument `staticArray` of type `char[256]` to parameter `char* destination`
static_array.c(9): Error: function `static_array.puts(char*)` is not callable using argument types `(char[256])`
static_array.c(9): cannot pass argument `staticArray` of type `char[256]` to parameter `char*`
Luckily .ptr works fine...