假設大約每四個版本我想生成編譯器警告,可能使用#warning
或者有條件地聲明應該生成溢出警告的int x = 3.14;
之類的東西。如何僅在某些時候生成編譯器警告?
我怎麼能這樣做,只使用前任?
有些問題看起來不錯,但我看不出如何生成隨機數之間和4或採取其所產生大量的模量:
How can I generate unique values in the C preprocessor?
How to generate a series of random numbers with the C/C++ preprocessor
Generate a random number using the C Preprocessor
[更新]我忘了說,我不得不C++ 2003 :-(
我把答案從Generate a random number using the C Preprocessor和剛添加
#if KISS/4 == 1
#warning Danger, Will Robinson!
#endif
但後來我得到
../test/main.cpp:105:5: error: token "=" is not valid in preprocessor expressions
參考線
#if KISS/4 == 1
凡KISS
擴張到
(((((z=36969*(z&65535)+(z>>16))<<16)+((w=18000*(w&65535)+(w>>16))&65535))^(jcong=69069*jcong+1234567))+(jsr=(jsr=(jsr=jsr^(jsr<<17))^(jsr>>13))^(jsr<<5)))
所以,它看起來像我需要不同的解決方案
你可以透露'main.cpp'的第105行嗎? –
#if KISS/4 == 1 – Mawg