如何用靈活的編譯方式編寫程序?如何編寫靈活編譯的程序?
#include "stdio.h"
void samplef(int d)
{
printf(....); // if d=1 no compile this line
printf(....); // else compile this line
}
如何用靈活的編譯方式編寫程序?如何編寫靈活編譯的程序?
#include "stdio.h"
void samplef(int d)
{
printf(....); // if d=1 no compile this line
printf(....); // else compile this line
}
我不確定你在問什麼,但這聽起來不太可能。
當程序運行時,編譯器在編譯程序時不知道d
的值是什麼。
我懷疑你可能誤解了「編譯」這個詞......?
你好我想在設計時編譯程序而不是運行時間 – onell 2011-03-04 18:20:35
預處理。您正在尋找preprocessing。
你可以用預處理器做這樣的事情,但總是會與定義,而不是與變量評估,因爲編譯器在編譯時不知道該值。
你不能控制基於函數參數的特定值的編譯,它們的值是在** runtime **處計算的,而不是**編譯時間** – Andrey 2011-03-04 18:16:04