Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用NativeCall缓解Rakudo中的错误?_C_Raku_Nativecall - Fatal编程技术网

如何使用NativeCall缓解Rakudo中的错误?

如何使用NativeCall缓解Rakudo中的错误?,c,raku,nativecall,C,Raku,Nativecall,我希望能够在具有REPR CStruct/CPointer的类中使用双指针: typedef结构密码上下文{ void*密码; const uint8_t*键; 大小键长度; const uint8_t*路径; 大小路径长度; 大小块大小; 无效*手柄; int(*cipher_init)(void**,const uint8_t*,size_t); int(*密码编码)(void*,const uint8\u t*,uint8\u t*,size\u t); int(*密码解码)(void*,

我希望能够在具有REPR CStruct/CPointer的类中使用双指针:

typedef结构密码上下文{
void*密码;
const uint8_t*键;
大小键长度;
const uint8_t*路径;
大小路径长度;
大小块大小;
无效*手柄;
int(*cipher_init)(void**,const uint8_t*,size_t);
int(*密码编码)(void*,const uint8\u t*,uint8\u t*,size\u t);
int(*密码解码)(void*,const uint8\u t*,uint8\u t*,size\u t);
无效(*无密码)(无效*);
const uint8_t*(*密码错误)(int);
}密码上下文;
int cipher\u context\u init(cipher context**,const uint8\u t*,size\u t,const uint8\u t*,size\u t,size\u t);
int cipher\u context\u encode(cipher context*,const uint8\u t*,uint8\u t*,size\u t);
int-cipher\u-context\u-decode(cipher-context*,const-uint8\u-t*,uint8\u-t*,size\u-t);
无效密码\u上下文\u自由(密码上下文*);
常数8*cipher\u context\u strerror(int);
Perl 6代码:

method new(Blob :$key!, Str :$path!, Int :$block-size!) {
    my Pointer[::?CLASS]     $ptr     .= new;
    my Int                   $err      = cipher_context_init($ptr, $key, $key.elems, $path, $path.codes, $block-size);
    return $ptr.deref unless $err;

    my Str $errstr = cipher_context_strerror($err) || do {
        my &cipher-strerror = nativecast(:(int32 --> Str), $!cipher-strerror);
        cipher-strerror($err)
    };
    die "Failed to initialize cipher context: $errstr";
}

submethod DESTROY() {
    cipher_context_free(self)
}
短高尔夫:

use v6.d;
use Nativecall;

class Foo is repr('CPointer') { 
    my Pointer[::?CLASS] $foo .= nw;
}

只是我不知道怎么做,因为有一个问题。有没有更好的方法来处理代码C部分中的错误(这就是为什么我要这样写的原因)?

失败的原因与失败的原因相同:

class Foo {...}

BEGIN Foo ~~ Bool; # <------

class Foo{
}

我猜真正的解决办法是将
Bool.ACCEPTS(Bool:U:\topic)
candidate更改为
Bool.ACCEPTS(Bool:U:Mu\topic)

我认为这是因为这也失败了,基本上是相同的错误:

Mu ~~ Bool

请提供更多信息。“拉库多的虫子”?你试了什么?它是怎么失败的?另外,请尽量避免给人留下这样的印象:这不是一个编程问题,即这是一个关于使用编辑器功能的问题。您想使用“在cipher_context_init中使用双指针并返回int”来对齐编辑器中的代码吗?我的坏@Yunnosch,我将包括更多信息,因此问题是一个错误,你已经报告给适当的人。你想在这里干什么?一个bug的解决方案?此外,有关StackOverflow的问题应包含所有必要的信息。链接被认为是一个弱点,因为它有不可用的风险。此外,所有信息都应该在问题本身中,而不是隐藏在注释中。“双指针”只是碰巧指向指针的指针。通常,您可以告诉Perl6它是一个指针,并确保正确设置它的值。
Mu ~~ Bool