编译错误,提示error C129: missing ';' 怎么解决
源文件“BASE64.C”代码
static BYTE base64_map[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static BYTE base64_decode_map[256] =
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 62, 0xff, 0xff, 0xff, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0xff, 0xff,
0xff, 0, 0xff, 0xff, 0xff, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
unsigned long encode(const BYTE* src, unsigned long src_len, BYTE *dst)
{
unsigned long group_count = src_len / 3; //数据流的24位分组 数目
unsigned long i, j;
if (group_count > 0)
{
for (i = 0; i < group_count - 1; i++)
{
dst[j++] = base64_map[ (src[i * 3] >> 2) & 0x3F ]; // FIRST BYTE 前 6 BIT
dst[j++] = ( (src[i * 3] << 4) & 0x30 ) + (src[i * 3 + 1] >> 4); //FIRST BYTE 余2位 补 SECOND BYTE 前 4 BIT & 0x03
dst[j++] = ( (src[i * 3 + 1] << 2) & 0x3C ) + (src[i * 3 + 2] >> 6); //SECOND BYTE 余4位 补 THIRD BYTE 前 2 BIT & 0x0F
dst[j++] = src[i * 3 + 2] & 0X3F; //THIRD BYTE 余 6 BIT
}
}
//剩余一个字节,8 BIT补 4BIT,输出2BYTE+两个等号
if (src_len % 3 == 1) {
dst[j++] = base64_map[(src[src_len - 1] >> 2) & 0x3F];
dst[j++] = base64_map[(src[src_len - 1] << 4) & 0x30];
dst[j++] = '=';
dst[j++] = '=';
}
else
if (src_len % 3 == 2) //剩余两个字节,16 BIT补 2BIT,输出3BYTE+一个等号
{
dst[j++] = base64_map[ (src[src_len - 2] >> 2) & 0x3F ];
dst[j++] = base64_map[ ((src[src_len - 2] << 4) & 0x30) + ((src[src_len - 1] >> 4) & 0xF)];
dst[j++] = base64_map[ (src[src_len - 1] << 2) & 0x3C ];
dst[j++] = '=';
}
dst[j] = 0;
return j;
}
unsigned long decode(const BYTE *src, unsigned long src_len, BYTE *dst)
{
unsigned long i = 0, j = 0;
for (i = 0; i < src_len; i += 4)
{
dst[j++] = base64_decode_map[src[i]] << 2 | base64_decode_map[src[i + 1]] >> 4;
dst[j++] = base64_decode_map[src[i + 1]] << 4 | base64_decode_map[src[i + 2]] >> 2;
dst[j++] = base64_decode_map[src[i + 2]] << 6 | base64_decode_map[src[i + 3]];
}
dst[j] = 0;
return j;
}
源文件“BASE64.h”代码
#ifndef _BASE64_H_
#define _BASE64_H_
unsigned long encode(const BYTE* src, unsigned long src_len, BYTE *dst);
unsigned long decode(const BYTE *src, unsigned long src_len, BYTE *dst);
#endif
编译提示“BASE64.C(3): error C129: missing ';' before 'base64_map'”
哪个地方出错了,怎么修改才能编译??
[解决办法]
BYTE 没有定义,需要typedef或者你改成unsigned char
[解决办法]
将static改成code看看
[解决办法]
static BYTE base64_decode_map[] =...
这是放DATA段的,要是{}内个数大于可使用RAM,就会出:
SEGMENT TOO LARGE
static code BYTE (或这里 code)base64_decode_map[256] =...
这样就放代码段了,一般flash比较大。
[解决办法]