所以,我有这个功能,但我遇到了一些我无法弄清楚的非常奇怪的错误。
void serialize_helper(huff *h, bits *history, char** a)
{
switch (h->tag) {
case LEAF:
char letter = h->h.leaf.c;
int arraynum = (int)letter;
a[arraynum] = bits_show(history);
putchar('\n');
return;
case NODE:
/* traverse left subtree */
bits_putlast('0',history);
serialize_helper(h->h.node.lsub,history, a);
bits_remove_last(history);
/* traverse right subtree */
bits_putlast('1',history);
serialize_helper(h->h.node.rsub,history, a);
bits_remove_last(history);
return;
default:
fprintf(stderr,"main.serialize_helper: bad tag\n");
exit(1);
}
}
对于一个简单的变量定义(来自 char letter = ...;),我收到此错误:
“huffenc.c:18: 错误: 'char' 之前的预期表达式”
此外,编译器的行为就像我对“字母”的声明不存在:“huffenc.c:19: error: 'letter' undeclared (first use in this function)”