【发布时间】:2013-12-22 07:33:50
【问题描述】:
我在 RELIC 库中看到了这样定义的类型 (fb_t)(此处为文档 https://code.google.com/p/relic-toolkit/downloads/list):
#if ALLOC == AUTO
typedef align dig_t fb_t[FB_DIGS + PADDING(FB_BYTES)/(FB_DIGIT / 8)];
#else
typedef dig_t *fb_t;
#endif
(align 定义为 /* empty */,如果重要的话)
所以它是一个指针,或者它是一个数组。但如果它是一个数组,那么这个函数将如何工作? (来自relic-doc/html/df/d96/relic__fb__util_8c_source.html#l00080)
void fb_copy(fb_t c, const fb_t a) {
for (int i = 0; i < FB_DIGS; i++) {
c[i] = a[i];
}
}
如果它是一个指针,这段代码将如何工作(因为它们是未初始化的指针)?
//create two variables
fb_t source, target;
fb_copy(target,source); //and copy one to the other
两者都在同一台计算机上运行。这台电脑上的sizeof(fb_t) 是 16。
【问题讨论】:
-
我只记得函数参数如何与数组类型一起使用。