看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) Linux 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) GCC 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) No 問題(Question): 看到一段code是這樣寫的: #define tmp_data(w) { w(0x11), w(0x22), w(0x33), w(0x44) } 想知道這段code要怎麼使用 可以怎麼印出來呢? 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.251.61.121 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1570962593.A.5BE.html
b0920075: gcc可以看預處理後的程式碼吧 10/13 18:32
loveme00835: 陣列初始化 10/13 18:54
Lipraxde: 編譯時加上 -E,如果是用 cmake 生成 makefile 的話可 10/13 19:09
Lipraxde: 以到目錄下 make [filename].i,應該會出現在 CMakefil 10/13 19:09
Lipraxde: es 目錄底下 10/13 19:09
[簡化程式碼後再gcc xxx.c -E] #include <stdlib.h> #define sb_data(w) {\ w(0x63), w(0x7c), w(0x77)} int main(){ return 0; } [結果如下] https://hackmd.io/0xBayZT8RfuPQBLIJ5Mi9g?view 但好像沒看到有用的資訊(?) 可以幫小弟解釋一下嗎~ ※ 編輯: Hack (60.251.61.121 臺灣), 10/14/2019 11:16:24
Lipraxde: 要看有用到那個 macro 的檔案 10/14 11:49
nh60211as: 你要實際使用那個macro啊 10/14 12:00
nh60211as: http://cpp.sh/5ycse 10/14 12:03
原來如此! 感謝教學~
mabinogi805: 還有這種作法…… 10/15 01:23
qscgy4: define 還有很多神奇的操作呢,這算簡單的 10/15 09:08
這種操作我已經覺得很神了XD ※ 編輯: Hack (61.218.44.76 臺灣), 10/17/2019 14:28:47