开发者

Applying compiler options to specific files

I am trying to compile and build a project(s) in visual studio and I started looking into compiling with the /Wall option which gives all warnings. I am wondering iof there is a way to run this only on those files I am interested in, since currently I get a million warnings on fi开发者_开发百科les i have no ability or desire to change.


In the Solution Explorer select the files you want all warnings for, right click and select Properties. From there you can adjust whatever compiler settings you want to for those files, just about like you would for the entire project.


Another approach that can work is to use the #pragma warning( ... ) modifiers.

This lets you controls specific warnings as well as the overall setting. See the documentation at http://msdn.microsoft.com/en-us/library/2c8f766e(v=vs.80).aspx

If a library or subproject causes a problem then you might be able to turn off warnings for it in a single place.

Modifying the project file for subsets of your files can get very messy very quickly, especially if you have multiple architectures and targets (debug, release, ...)

I prefer to modify the project files by hand in a text editor for this type of change so I am sure that everything is happening as expected.


If there is a Makefile (or equivalent) for your part of the project (e.g. a directory), then you may be able to add the the /Wall warning flag only for that part

WARNING_FLAGS += /Wall

(It still is not per file, but this may be more manageable.)

Another option is to put all the warning messages and filter (e.g. grep) for the file names you are interested.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜