[Issue 22251] New: ImportC: Array -> Pointer implicit conversion does not work
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 30 03:17:58 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22251
Issue ID: 22251
Summary: ImportC: Array -> Pointer implicit conversion does not
work
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: maxhaton at gmail.com
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...
--
More information about the Digitalmars-d-bugs
mailing list