mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Carbon only supports f64, so only double can be mapped. https://github.com/carbon-language/carbon-lang/blob/30f0ddab71bda71f8789080962b1fe8a5938e327/toolchain/check/type.cpp#L54 C++ Interop Demo: ```c++ // hello_world.h auto hello_world(double x) -> void; ``` ```c++ // hello_world.cpp #include "hello_world.h" #include <cstdio> auto hello_world(double x) -> void { printf("double: %f\n", x); } ``` ```carbon // main.carbon library "Main"; import Cpp library "hello_world.h"; fn Run() -> i32 { Cpp.hello_world(0.25); return 0; } ``` ```shell $ clang -c hello_world.cpp $ bazel-bin/toolchain/carbon compile main.carbon $ bazel-bin/toolchain/carbon link hello_world.o main.o --output=demo $ $ ./demo double: 0.250000 ``` Before this change: ```shell $ bazel-bin/toolchain/carbon compile main.carbon main.carbon:8:3: error: semantics TODO: `Unsupported: parameter type: double` Cpp.hello_world(0.25); ^~~~~~~~~~~~~~~ main.carbon:8:3: note: in `Cpp` name lookup for `hello_world` Cpp.hello_world(0.25); ^~~~~~~~~~~~~~~ ``` Part of #5263.