報(bào)錯(cuò)如下:
main.c(116): main.c(116): error: ?#20: identifier "g_pol_par_linear" is undefined
main.c(99): error: ?#20: identifier "g_motor_sta_linear" is undefined
main
#include "Interpolation_Linear.h" //Interpolation_Linear.c里定義了g_pol_par_linear
int main(void)
{
g_pol_par_linear.moving_mode = 1;
while(g_motor_sta_linear);
printf("圓弧插補(bǔ)\r\n");
}
Interpolation_Linear.c
//結(jié)構(gòu)體
inter_pol_def g_pol_par_linear= {0}; /* 直線插補(bǔ)參數(shù)值 */
//枚舉
__IO st_motor_status_def g_motor_sta_linear = STATE_STOP_linear; /* 步進(jìn)電機(jī)運(yùn)動(dòng)狀態(tài) */
我認(rèn)為在主函數(shù)里引用了“Interpolation_Linear”的頭文件,就包含了里面定義的變量。
但是會(huì)報(bào)錯(cuò)。
解決辦法:在主函數(shù)加extern聲明。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-729582.html
#include "Interpolation_Linear.h" //Interpolation_Linear.c里定義了g_pol_par_linear
extern inter_pol_def g_pol_par_linear; //直線插補(bǔ)模式
extern st_motor_status_def g_motor_sta_linear; //直線插補(bǔ) 運(yùn)動(dòng)模式
int main(void)
{
g_pol_par_linear.moving_mode = 1;
while(g_motor_sta_linear);
printf("圓弧插補(bǔ)\r\n");
}
加入聲明后報(bào)錯(cuò)消失。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-729582.html
到了這里,關(guān)于keil報(bào)錯(cuò):main.c(99): error: #20: identifier “xxx“ is undefined的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!