void 被compiler 看成 oid

2019-07-20 21:15发布

想要寫一個 max6675 的程序
但是
compiler 似乎把 void max6675_Init() 看成 oid max6675_Init()

所以,寫了兩個空函式測試
void max6657_Init(){}

int max6675_Init(){}

如果宣告成 void 會出現錯誤如下
------------------------------------
*** Using Compiler 'V5.05 update 2 (build 169)', folder: 'C:Keil_v515ARMARMCCBin'
Build target 'SPI'
compiling max6675.c...
..HARDWAREmax6675.c(4): error:  #260-D: explicit type is missing ("int" assumed)
  
oid max6675_Init(){}
..HARDWAREmax6675.c(4): error:  #260-D: explicit type is missing ("int" assumed)
  
oid max6675_Init(){}
..HARDWAREmax6675.c(38): warning:  #1-D: last line of file ends without a newline
  //
..HARDWAREmax6675.c: 1 warning, 2 errors
"..OBJSPI.axf" - 2 Error(s), 1 Warning(s).
-------------------------------------------------------------------------------

void 錯誤 void 錯誤
貌似 compiler 把 void 視為 oid


如果宣告成 int 則不會有錯誤
但會出現 缺少 return 的 warning
int int

請前輩指導一下,這到底是怎樣的錯誤
要如何修正?!
感謝您的回應

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
lvehe
1楼-- · 2019-07-20 21:58
 精彩回答 2  元偷偷看……
ianhom
2楼-- · 2019-07-21 03:01
是不是哪里有 #define v (空格)了?预编译完就把"v"全弄没了
KCLin
3楼-- · 2019-07-21 08:59
感謝。。。
我把 void max6675_Init(void) 多弄了個 define

BTW, 函式不是都要在 .h 裡宣告型態嗎?
所以,我才在 .h 裡有了這一行
只是
可能因為太順手,多了 #define
然後看了幾個小時看不出來 Orz

無論如何,感謝您的指正!

一周热门 更多>