Skip to content

[Carbon/C++ interop] Add support for C++ type short #5393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 9, 2025

Conversation

ivanaivanovska
Copy link
Contributor

@ivanaivanovska ivanaivanovska commented Apr 30, 2025

Added support for short/int16_t. Both function parameters and return values this type will be supported.

Demo:

// hello_short.h

#include <cstdint>
auto foo_short(int16_t a) -> int16_t;
// hello_short.cpp

#include "hello_short.h"
#include <cstdio>

auto foo_short(int16_t a) -> int16_t {
    printf("a = %i \n", a);
    return a;
}
// main.carbon

library "Main";

import Cpp library "hello_short.h";
import Core library "io";

fn Run() -> i32 {
  var a: i16 = 3;
  Cpp.foo_short(a);
  return 0;
}
$ clang -c hello_short.cpp
$ bazel-bin/toolchain/carbon compile main.carbon
$ bazel-bin/toolchain/carbon link hello_short.o main.o --output=demo
$ ./demo
a = 3 

Part of #5263

@github-actions github-actions bot requested a review from danakj April 30, 2025 13:42
@bricknerb bricknerb self-requested a review May 5, 2025 11:51
@ivanaivanovska ivanaivanovska requested review from danakj and bricknerb May 5, 2025 13:42
@ivanaivanovska ivanaivanovska requested review from danakj and bricknerb May 6, 2025 12:41
Copy link
Contributor

@danakj danakj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ivanaivanovska ivanaivanovska requested a review from bricknerb May 8, 2025 08:29
@bricknerb bricknerb enabled auto-merge May 9, 2025 08:41
@bricknerb bricknerb added this pull request to the merge queue May 9, 2025
Merged via the queue into carbon-language:trunk with commit f8443ae May 9, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants