digitalmars.D.bugs - [Issue 22251] New: ImportC: Array -> Pointer implicit conversion
- d-bugmail puremagic.com (38/38) Aug 29 2021 https://issues.dlang.org/show_bug.cgi?id=22251
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 puremagic.com Reporter: maxhaton 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... --
Aug 29 2021