函數(shù)指針編譯時(shí)出錯(cuò)怎么辦?
1. 問(wèn)題
粉絲提問(wèn):某個(gè)函數(shù)指針的使用:編譯時(shí)出錯(cuò)了。
type defaults to 'int' in declaration of 'on_touch_messgae_h(yuǎn)andle'[-Wimplicit-int] typedef(*on_touch_messgae_h(yuǎn)andle)(touch_message_t);
粉絲源碼如下:
2. 分析
1) 結(jié)構(gòu)解析
1 struct touch_message
2 {
3 rt_uint16_t x;
4 rt_uint16_t y;
5 rt_uint8_t event;
6 };
7 typedef struct touch_message * touch_message_t;
8 typedef (*on_touch_messgae_h(yuǎn)andle)(touch_message_t);
首先看下7行這個(gè)類型定義:
typedef struct touch_message * touch_message_t;
定義后
touch_message_t
等價(jià)于
struct touch_message *
就是說(shuō)我們?nèi)绻胻ouch_message_t 定義的變量是一個(gè)struct touch_message類型的一個(gè)指針。
再來(lái)分析下8行這個(gè)定義:
typedef (*on_touch_messgae_h(yuǎn)andle)(touch_message_t);
可以替換成下面這個(gè)定義
typedef (*on_touch_messgae_h(yuǎn)andle)(struct touch_message *);
發(fā)表評(píng)論
請(qǐng)輸入評(píng)論內(nèi)容...
請(qǐng)輸入評(píng)論/評(píng)論長(zhǎng)度6~500個(gè)字
最新活動(dòng)更多
-
即日-10.29立即報(bào)名>> 2024德州儀器嵌入式技術(shù)創(chuàng)新發(fā)展研討會(huì)
-
10月31日立即下載>> 【限時(shí)免費(fèi)下載】TE暖通空調(diào)系統(tǒng)高效可靠的組件解決方案
-
即日-11.13立即報(bào)名>>> 【在線會(huì)議】多物理場(chǎng)仿真助跑新能源汽車
-
11月14日立即報(bào)名>> 2024工程師系列—工業(yè)電子技術(shù)在線會(huì)議
-
12月19日立即報(bào)名>> 【線下會(huì)議】OFweek 2024(第九屆)物聯(lián)網(wǎng)產(chǎn)業(yè)大會(huì)
-
即日-12.26火熱報(bào)名中>> OFweek2024中國(guó)智造CIO在線峰會(huì)
推薦專題
- 1 Intel宣布40年來(lái)最重大轉(zhuǎn)型:年底前裁員15000人、拋掉2/3房產(chǎn)
- 2 因美封殺TikTok,字節(jié)股價(jià)骨折!估值僅Meta1/5
- 3 宏山激光重磅發(fā)布行業(yè)解決方案,助力智能制造產(chǎn)業(yè)新飛躍
- 4 國(guó)產(chǎn)AI芯片公司破產(chǎn)!白菜價(jià)拍賣
- 5 具身智能火了,但規(guī)模落地還需時(shí)間
- 6 國(guó)產(chǎn)英偉達(dá)們,抓緊沖刺A股
- 7 三次錯(cuò)失風(fēng)口!OpenAI前員工殺回AI編程賽道,老東家捧金相助
- 8 英特爾賦能智慧醫(yī)療,共創(chuàng)數(shù)字化未來(lái)
- 9 英偉達(dá)的麻煩在后頭?
- 10 將“網(wǎng)紅”變成“商品”,AI“爆改”實(shí)力拉滿
- 高級(jí)軟件工程師 廣東省/深圳市
- 自動(dòng)化高級(jí)工程師 廣東省/深圳市
- 光器件研發(fā)工程師 福建省/福州市
- 銷售總監(jiān)(光器件) 北京市/海淀區(qū)
- 激光器高級(jí)銷售經(jīng)理 上海市/虹口區(qū)
- 光器件物理工程師 北京市/海淀區(qū)
- 激光研發(fā)工程師 北京市/昌平區(qū)
- 技術(shù)專家 廣東省/江門市
- 封裝工程師 北京市/海淀區(qū)
- 結(jié)構(gòu)工程師 廣東省/深圳市