更新时间:2023-01-14 15:22:38
如何仅对部分源代码禁用
[C ++警告] W8066无法访问的代码
?
您可以使用 #pragma warn
语句包装代码:
You can wrap the code with #pragma warn
statements:
#pragma warn -8066 // disable W8066 warnings
<code>
#pragma warn .8066 // restore W8066 warnings back to default
否则,我建议仅复制宏,注释掉原始宏,然后根据需要修改副本以删除所需的代码.
Otherwise, I would suggest just making a copy of the macro, comment out the original, and modify the copy to remove the desired code as needed.
/*
#define some_macro \
bla; \
bla; \
if (0) \
{ \
bla; \
bla; \
bla; \
} \
bla;
*/
#define some_macro \
bla; \
bla; \
bla;
或者,您可以在原始宏中注释掉所需的代码:
Or, you could just comment out the desired code inside the original macro:
#define some_macro \
bla; \
bla; \
//if (0) \
// { \
// bla; \
// bla; \
// bla; \
// } \
bla;