看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) Linux 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) GCC 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 請問下面網址內的程式碼 第26行~48行, 執行結果會認為variable a1的值是0 原因是preprocessor展開的時候還沒compile, 所以將不認得的variable當成0來看待嗎? 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) https://ideone.com/LmmXtE 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.34.226.230 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1668011007.A.958.html
shibin: 我只知道#if通常用在判斷是否已定義,不知能否判斷數值 11/10 00:50
shibin: 我說的定義是#define al,不是int a1; 11/10 00:50
Dracarys: 對 https://eel.is/c++draft/cpp.cond#11 11/10 00:53
Richun: 判斷定義與否應該是#ifdef跟#ifndef 11/10 01:00
gusion: #if可以判斷define的數值,像是linux kernel就有version的 11/10 08:54
gusion: define值,寫module時可以用來判斷用不同版本的kernel要co 11/10 08:54
gusion: mpile哪段code 11/10 08:54
shibin: 長知識了 11/10 11:25
wulouise: #define不能跟變數混在一起.. #if只看#define 11/10 23:21
CoNsTaR: 為什麼會有這種需求?meta-programming? 11/11 03:38
s9041200: 4 11/12 22:51