Ivana Ivanovska
7580df8b8a
[Carbon/C++ interop] Add support for int function params (#5197)
Added support for `int` function parameters. Currently only
pass-by-value is supported.
```c++
// hello_int.h;
auto foo_int(int a, int b) -> int;
```
```c++
// hello_int.cpp
#include "hello_int.h"
#include <cstdio>
auto foo_int(int a, int b) -> int {
printf("a = %i \n", a);
printf("b = %i \n", b);
return a + b;
}
```
```c++
// main.carbon
library "Main";
import Cpp library "hello_int.h";
import Core library "io";
fn Carbon_foo(b: i32) {
Core.Print(b);
}
fn Run() -> i32 {
Carbon_foo(Cpp.foo_int(2, 8));
return 0;
}
```
```
$ clang -c hello_int.cpp
$ bazel-bin/toolchain/carbon compile main.carbon
$ bazel-bin/toolchain/carbon link hello_int.o main.o --output=demo
$ ./demo
a = 2
b = 8
10
```
Part of #5064
2025-04-09 11:38:39 +00:00
..
2025-04-08 19:10:49 +00:00
2025-04-08 00:40:21 +00:00
2025-04-03 21:14:03 +00:00
2025-04-08 19:10:49 +00:00
2025-04-01 20:24:00 +00:00
2025-04-03 21:14:03 +00:00
2025-04-08 22:21:44 +00:00
2025-04-03 21:14:03 +00:00
2025-04-03 21:14:03 +00:00
2025-04-03 21:14:03 +00:00
2025-03-04 23:28:42 +00:00
2025-04-08 21:04:30 +00:00
2025-04-08 21:04:30 +00:00
2025-04-08 22:21:44 +00:00
2025-03-10 16:00:35 +00:00
2025-03-10 16:00:35 +00:00
2025-04-08 19:10:49 +00:00
2025-04-08 22:21:44 +00:00
2025-04-03 21:14:03 +00:00
2025-04-08 19:10:49 +00:00
2025-04-09 11:38:39 +00:00
2025-03-10 16:00:35 +00:00
2025-04-08 19:10:49 +00:00
2025-04-08 19:10:49 +00:00
2025-04-08 19:10:49 +00:00
2025-03-26 22:53:32 +00:00
2025-04-08 19:10:49 +00:00
2025-04-05 16:08:09 +00:00
2025-04-03 21:14:03 +00:00
2025-04-08 19:10:49 +00:00
2025-04-08 19:10:49 +00:00
2025-04-08 19:10:49 +00:00
2025-04-08 19:10:49 +00:00
2025-04-08 19:10:49 +00:00
2025-03-31 15:45:58 +00:00