명령 행에서 자세한 정보 수준을 지정하는 시스템이 있습니다.전처리 기가 코드 블록을 처리하도록하기
#ifdef DEBUG
if (verbose_get_bit(verbose_level_1)) {
// arbitrary debugging/printing style code generally goes in here, e.g.:
printf("I am printing this because it was specified and I am compiling debug build\n");
}
#endif
내가 그래서 여기까지 설정이 덜 지루한하고 싶습니다 지금까지이 작업은 다음과 같습니다 : 내 기능에서 나는 코드 블록 여부를 입력하면 결정하기 위해 지정된 있었는지에 대해 확인
이제// from "Verbose.h"
bool verbose_get_bit(verbose_group_name name); // verbose_group_name is an enum
#ifdef DEBUG
#define IF_VERBOSE_BIT_D(x) if (verbose_get_bit(x))
#else // not debug: desired behavior is the entire block that follows gets optimized out
#define IF_VERBOSE_BIT_D(x) if (0)
#endif // not debug
,이 작업을 수행 할 수 있습니다 : 그것은 경우 문처럼, 그것은, 그것은 매크로의 것이 분명는 IF 문으로 기능하고, 그렇지 않은 보이기 때문에
IF_VERBOSE_BIT_D(verbose_GL_debug) {
printf("I don't want the release build to execute any of this code");
glBegin(GL_LINES);
// ... and so on
}
좋아요 릴리스 빌드에서 실행하십시오.
if(false)
블록으로 래핑 될 것이므로 코드가 최적화 될 것이라고 확신 할 수 있지만 실제로는 전체 블록을 버리는 전처리기를 얻을 수있는 방법이 있다면 선호합니다. 할 수 있습니까?
'verbose_get_bit'에 대한 인수를 넘어 명세서에서 달라질 수있는 내용이 있는지 확인하십시오. – outis
@ BrianTompsett- 汤 莱恩 : C++에서 작동하지 않습니까? – usr2564301