简体   繁体   中英

#pragma warning - file specific?

Simple question, but I can't seem to find an answer in any reference material.

If I have a #pragma warning() directive, does the compiler only define that for the current file? Or is it propagated through #includes in other files in my project?

This is probably a wider question, which isn't necessarily specific to #pragma, but that is the case I am particularly worried about.

If you put the directive in a header, it will affect any other file that includes that header. It will also affect any headers included after you use it. If you are worried about affecting other files with your use of this, you can use #pragma warning (push) and #pragma warning (pop) to undo any changes you only want to make locally to one file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM