[問題] cast array of int to array of pointer
問題(Question):
好奇一件事:
我現在有很多個硬體IO address,想寫成array of pointers去存取它
int * const port_dir[10]={(int*)0x42128005, (int*)0x42128000, (int*)0x42188004,
(int*)0x42128001, (int*)0x42188005, (int*)0x42128004,................}
在宣告/定義的時候, 除了上面這樣, 還有什麼方法initialize一堆pointer嗎?
像是 int * const port_dir[10]=(cast?){...} 不過這種還是make pointer from integer
覺得上面這樣寫很... 重複
除了寫成macro這種只是藏起來的方法
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.169.194.43
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1433255494.A.CD2.html
→
06/02 22:33, , 1F
06/02 22:33, 1F
→
06/02 22:38, , 2F
06/02 22:38, 2F
→
06/02 22:39, , 3F
06/02 22:39, 3F
→
06/02 22:40, , 4F
06/02 22:40, 4F
→
06/02 22:40, , 5F
06/02 22:40, 5F
→
06/02 22:40, , 6F
06/02 22:40, 6F
→
06/02 22:41, , 7F
06/02 22:41, 7F
→
06/02 22:42, , 8F
06/02 22:42, 8F
→
06/02 22:43, , 9F
06/02 22:43, 9F
→
06/02 23:07, , 10F
06/02 23:07, 10F
→
06/03 16:07, , 11F
06/03 16:07, 11F