考虑这些 C 函数:
#define INDICATE_SPECIAL_CASE -1
void prepare (long *length_or_indicator);
void execute ();
准备函数用于存储指向延迟long *
输出变量的指针。
它可以像这样在C中使用:
int main (void) {
long length_or_indicator;
prepare (&length_or_indicator);
execute ();
if (length_or_indicator == INDICATE_SPECIAL_CASE) {
// do something to handle special case
}
else {
long length = lengh_or_indicator;
// do something to handle the normal case which has a length
}
}
我试图在 Vala 中实现这样的目标:
int main (void) {
long length;
long indicator;
prepare (out length, out indicator);
execute ();
if (indicator == INDICATE_SPECIAL_CASE) {
// do something to handle special case
}
else {
// do something to handle the normal case which has a length
}
}
如何为prepare ()
和INDICATE_SPECIAL_CASE
在 Vala 中编写绑定?
是否可以将变量一分为二?
即使在调用(in )out
之后写入变量,是否可以避免使用指针?prepare ()
execute ()