在编写输入法时,用到的一个结构数组,在结构数组中由于导入了太多的汉字导致堆栈溢出,其实就是RAM不够用了,因为程序中默认将全局的数组和变量放到RAM中去,我用的是MSP430F149它的RAM有2k,还不小,但是我的汉字太多,导致2k的RAM也不够了,程序如下:
struct t9PY_index
{
unsigned char *t9PY_T9;
unsigned char *PY;
unsigned char *PY_mb;
};
struct t9PY_index t9PY_index2[] ={{"2","a","阿啊"},
{"3","e","讹俄娥峨鹅蛾额厄扼恶饿鄂遏"},
{"4","i","阿啊"},
{"5","l","厘梨狸"},
{"6","o","哦"},
{"7","p","阿啊"},
{"8","u","阿啊"},
{"9","w","阿啊"},
{"22","ba","八巴叭扒吧芭疤捌笆拔跋把靶坝爸罢"},
{"22","ca","擦"},
{"23","ce","册侧厕测策"},
{"24","ai","哎哀唉埃挨皑癌矮蔼艾爱隘碍"},
{"24","ci","疵词茨瓷慈辞磁雌此次刺赐"},
{"26","an","安氨鞍俺岸按案胺暗"},
{"26","ao","凹敖熬翱袄傲奥澳懊"},
……………………….
}
但是ROM有64k啊,如果可以放到ROM中就可以解决了,然后我查了一下,发现果真可以,而且很简单,只需加个const就可以了,这样它就不会把这个分配到ROM中去调用,同时也需将调用的变量也加const,这样匹配后就可以了,问题就ok了。
文章评论(0条评论)
登录后参与讨论