What is the scope of a pragma directive?
问题 What is the scope of a pragma directive? For example, if I say #pragma warning(disable: 4996) in a header file A that is included from a different file B, will that also disable all those warnings inside B? Or should I enable the warning at the end of file A again? 回答1: It is till the end of the translation unit. Informally, a TU is the source file with its include files. The usual pattern is this: #pragma warning (push) //save #pragma warning (disable: xxxx) #pragma warning (disable: yyyy) .