mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:50:14 +01:00
Support passing Carbon Optional(T*) to C++ T* parameter. (#6422)
We already did this translation in the other direction, but we had no mapping from `Optional(T)` to anything, so round-tripping a nullable pointer from C++ through Carbon and back to C++ was previously rejected.
This commit is contained in:
@@ -27,10 +27,9 @@ fn HelloPutchar() {
|
||||
|
||||
// Demonstrate passing a null-terminated string to a C++ function.
|
||||
fn HelloStdio() {
|
||||
// TODO: Requires mapping from Optional(const char*) into C++.
|
||||
// TODO: There should be a better way to interact with functions that expect a
|
||||
// null-terminated string.
|
||||
// Cpp.puts(Cpp.std.data("Hello world!\n\0"));
|
||||
Cpp.puts(Cpp.std.data("Hello world!\0"));
|
||||
|
||||
// TODO: Requires variadic function support.
|
||||
// Cpp.printf("Hello world!\n\0");
|
||||
@@ -38,7 +37,7 @@ fn HelloStdio() {
|
||||
|
||||
// Demonstrate passing a string as a void pointer to a C++ function.
|
||||
fn HelloWrite() {
|
||||
// TODO: Requires mapping from Optional(const char*) into a C++ const void*.
|
||||
// TODO: Requires conversion from `const char*` to `const void*`.
|
||||
// let s: str = "Hello world!\n";
|
||||
// Cpp.write(1, Cpp.std.data(s), Cpp.std.size(s));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user