ããªããã»ããµãããã¬
æ¨æ¥ã®ãã¨ãé©å½ã«ã¾ã¨ãã¦ã¿ãã
å§ã¾ãã¯ãã®ã¤ã¶ããããã
ãæ¥åããã®ã³ã¼ãããã¾ãåãçç± http://codepad.org/IwJ4sqA9
http://twitter.com/DecimalBloat/status/9965596581
ãããè¦ã¦ãããããã° id:y-hamigaki ããã Boost.Wave を使ってプリプロセス時デバッグする方法を書いていたãã¨ãæãåºããã®ã§ãå®éã« wave.exe ã使ã£ã¦ã¿ã¾ããã
wave.exe ã使ãã
ã¾ã wave.exe ãã©ãã«ãããããããè¦æ¦ã
調ã¹ã¦ã¿ã㨠boost/tools/wave ã«ããã¿ãããªã®ã§ãããããã½ã¼ã¹ãæã£ã¦ãã¦é©å½ã«ãã«ãã
ã§ãæåã®é ã®ããããã½ã¼ã¹ãã³ãããã¦ã
#pragma wave trace(enable)
ãã©ããã«è¿½å ãã¦ã
wave.exe -S"C:\Program Files\boost\boost_1_42" -ttrace.txt --timer --variadics crazy.h
ã¨ãå®è¡ãã¦ã¿ãã¨ï½¥ï½¥ï½¥
warning: PP_IS_EMPTY_VIII: too few macro arguments
ã¨ãæããã¾ããã
PP_IS_EMPTY_VIII ã®å®ç¾©ã¯
#define PP_IS_EMPTY_VIII(a, ...) PP_IS_EMPTY_IX((HELPER_IV_ ## a))
ã¨ãªã£ã¦ãã¦ãããã«å¯¾ãã¦å¼æ°1ã¤ã§å¼ã³åºãã¦ã¿ãã¨ã¨ã©ã¼ã«ãªãããã§ãã
念ã®ãã以ä¸ã®ãããªã³ã¼ãã試ãã¦ã¿ã¾ããã
#define HOGE(...) HOGE() // OK #define HOGE2(a, ...) HOGE2(A) // ã¨ã©ã¼
ãã Boost.Wave ã®ãã°ãããï¼ã¨æã£ãã®ã§ãããä¸å¿ C99 ã®è¦æ ¼ãéãã¦ã¿ããã¨ã«ã
ããã¨ï½¥ï½¥ï½¥
there shall be more arguments in the invocation than there are parameters in the macro definition (excluding the ...).
N1256 §6.10.3¶4
ã¨ãæ¸ãã¦ã¾ããã ... ãé¤ããå¼æ°ã®æ°ããå¼ã³åºãæã®å¼æ°ã®æ°ã®æ¹ãå¤ããªãã¨ãããªãããã§ãã
HOGE2 㯠... ãé¤ããå¼æ°ã®æ°ã 1 åãå¼ã³åºãæã®å¼æ°ã 1 åãªã®ã§ã¨ã©ã¼ã«ãªã£ã¦ããã¨ã
HOGE ã OK ãªã®ã¯ã空ãã¼ã¯ã³ãä¸ã¤ã®å¼æ°ã¨èªèãã¦ãããããããã§ãã
çã£ã¦ããããªãã Boost.Waveãããªãã¯æ£ããã£ãã
ã¨ãããã¨ã§ããã id:DigitalGhost ããã«å ±åããã¨ãããPP_IS_EMPTY_V ã以ä¸ã®ããã«ä¿®æ£ããã°ããããã¨ãããã¨ã§ãã
#define PP_IS_EMPTY_V(a, ...) PP_IS_EMPTY_VI((a __VA_ARGS__ (), NIL))
ã§ãå度 wave.exe ã«æãã¦ã¿ãã¨ã1 㨠6 ãåºåããã¦ããã°ãåãã¾ããã
çµæã¯ãã¡ãã
ããã ã詳細ã«ãã°ãåºã¦ããã°ããã¾ãåãçç±åããã¾ãããï¼èªåã¯è¦ãæ°ããã¾ãããã
wave.exe ããã£ã¨ä½¿ã£ã¦ã¿ã
調åã«ä¹ã£ã¦ãDigitalGhost ããã® Preprocessor の記事ã wave.exe ã«æãã¦ã¿ã¾ããã
ããã¤ãã¯çµæè¦ã¦é¢ç½ãé¢ç½ãã¨ãã£ã¦è¨ã£ã¦ãã®ã§ãããプリプロセス時 FizzBuzz ã®ã½ã¼ã¹ããã£ã¦ã¿ãã¨ãããããã¨ã«ã
æåã¯ãããã°ã¢ã¼ã㧠VS ä¸ããå¦çãæãã¦ããã®ã§ããããããã㨠Stack overflow 㧠wave.exe ãè½ã¡ã¾ããã
ä»æ¹ãªãã®ã§ãªãªã¼ã¹ãã«ããã¦ã³ãã³ãã©ã¤ã³ããç´æ¥å©ããã®ã§ãããå¦çãæ»ã£ã¦ãã¾ããã
ããã§ã延ã
ã¨å¾
ã¡ç¶ãããã¨20åãããããå¦çãæ»ã£ã¦ãã¦ãæ£ããåºåããã¾ããã
ã§ããã°ãã¡ã¤ã«ãè¦ã㨠15,092,097,953 byteã
ãã®ãã°ããèªãã°ããªãããã£ã¨ã³ã³ãã¤ã«æ FizzBuzz ã®ä»çµã¿ãåããããã«ï¼ãµããããªã
ã¾ã¨ã
Boost.PP ãããã使ãã¾ãã£ã¦ããã§ããã³ã¼ãã追ã£ã¦ããã¨ãã°ãè¨å¤§ãªãã¨ã«ãªãã®ã§ããã㯠wave.exe ã®ã½ã¼ã¹ãå¼ã£ã¦ BOOST_* ã®ãã°ãåºããªãããã«ããããããã®ãã°ãã¥ã¼ã¯ãä½ã£ã¦ç¹å®ã®é¨åã ãé ãã¨ãã®å¯¾çãããªãã¨ã¾ã¨ãã«èªãããã«ãªãã§ãã
ãã å°ããã³ã¼ãã§ã®ããªããã»ã¹ã追ãã®ã§ããã°ãwave.exe ã¯ããªã使ãããã§ãã
ä¾ãã° 1から10まで足すんだって、プリプロセッサで - デ-mk6 ãªããã¯ãã°ã®ãµã¤ãºã 1.3MB ç¨åº¦ãªã®ã§ãã¾ãèªããªããã¨ãç¡ãã¨æãã¾ãã
ã¨ãããã¨ã§ããªããã»ã¹æãããã°ãªã wave.exe ã使ãã¨ãããï¼ã¨ããã話ã§ããã