通过预处理器禁用或启用代码 [英] Disable or enable code by preprocessor
本文介绍了通过预处理器禁用或启用代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C ++中,我会写
bool positive (int a)
{
#ifdef DEBUG
cout << "Checking the number " << a << "\n";
#endif
return a > 0;
}
在OCaml中我可以写
In OCaml I could write
let positive x =
begin
printf "Checking the number %d\n" x;
x > 0
end
但是在不处于调试模式时如何禁用printf语句?
But how can I disable the printf statement when not in debug mode?
推荐答案
您可以使用cppo: https://github .com/mjambon/cppo . 可通过opam获得此功能,并提供类似C的预处理器功能.
you can use cppo : https://github.com/mjambon/cppo. This is available via opam, and offers C like preprocessor features.
这篇关于通过预处理器禁用或启用代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文