欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__‘問題解決

作者:huqin   來源:本站原創   點擊數:  更新時間:2014年03月13日   【字體:

今天寫了一段比較簡單的C語言程序,但是在編譯的時候卻遇到了一個不怎么常見的錯誤,特此做一個簡單的總結。
 
我采用gcc編譯的過程中出現了如下的一些錯誤:
[gong@Gong-Computer hashmap]$ gcc -g testlist.c list.c -o testlist
In file included from testlist.c:3:0:
list.h:28:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘create_list’
list.h:29:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘insert_listnode’
list.h:30:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘delete_listnode’
In file included from list.c:4:0:
list.h:28:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘create_list’
list.h:29:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘insert_listnode’
list.h:30:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘delete_listnode’
list.c:6:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘create_listnode’
list.c:19:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘create_list’
list.c:33:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘insert_listnode’
list.c:76:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘delete_listnode’
這種錯誤在我前面寫代碼的時候很少看見,我也不知道是怎么了,然后我又采用g++的編譯器進行了一次編譯,竟然通過了。所以我覺得肯定是編譯器存在問題。
 
這個讓我有些不知所措,通過查找網頁,發現了這個問題出現的原因。
 
出現這種錯誤是因為bool類型錯誤,因為我在程序中返回了false,true以及bool類型,但是在C語言中是不存在布爾類型的數據的,這就是出現錯誤的原因。
 
找到的原因通過宏定義即可解決上面出現的問題:
#define bool int
#define true 1
#define false 0
 
添加好這幾個宏定義以后,編譯器竟然沒有問題了。

關閉窗口

相關文章