通过LLVM按参数传递结构 [英] Pass structure by parameter with LLVM

查看:73
本文介绍了通过LLVM按参数传递结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过参数传递结构?

Is it possible to pass structure by parameter ?

它与Cabi兼容吗?

基本上,我希望有一个C ++ POD,它将包含两个成员(该结构将是一个胖指针,带有一个指针和一个整数),并且能够将该结构作为函数参数传递给调用指令(甚至调用C代码时).

Basically, I would like to have a C++ POD which would contain two members (the structure would be a fat pointer, with a pointer and an integer), and be able to pass this structure as function parameter in call instructions (even when calling C code).

我现在不使用胖指针(指针和整数分别在不同的函数参数中),我想知道在开始大型重构之前是否有可能!

I'm not using fat pointer now (the pointer and the integer are each in a different function parameter), and I would like to know if it's possible before starting a pretty big refactoring !

推荐答案

当然可以.这是一个示例:

Absolutely, you can. Here's an example:

struct MyStruct_t {
    char *charPointer;
    int number;
};

void myFunction(MyStruct_t myStructAsParam) {

    printf("String: %s, Number: %i", myStructAsParam.charPointer, myStructAsParam.number);
    // Your stuff here.
}

这篇关于通过LLVM按参数传递结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆