Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top