I have just started working with C++ code compiled in Visual Studio 2008. The default warning level on the project was set to 3 and there were no warnings. I turned this up to level 4, and it turns out that there are about 35000 warnings in our code. The majority of these warnings are unreferenced formal parameters, which I'd like to remove eventually.
In the meantime, I would like to make sure that any level 3 or lower warnings stand out from the crowd, so I was wondering if there was a way of making these particular warnings be treated as errors. I'm aware that specific warnings can be tagged as errors, but I can't find any listings for error numbers.
I was wondering if anybody might have any suggestions about how to deal with this?
You could make two separate build configurations, one showing warnings level 3, and one shows level 4 as well. Then when you're not working on fixing warnings, use the level 3 configuration. If you do go down this route, you might want to look into using property sheets, so you can reuse as much as possible of the configuration, instead of having to duplicate it.
I don't think there's any way to treat warnings L1-3 as errors, while still allowing/showing L4 warnings.
I have now compiled a list of all the warnings at different levels. I used http://msdn.microsoft.com/en-us/library/8x5x43k7(v=VS.90).aspx as my reference. Here they are, use at your own peril:
// level 2 & 3: #pragma warning ( error : 4008 ) // level 1 & 3 #pragma warning (error : 4793 ) // level 1 & 4 #pragma warning (error : 4112 4115 4223 4355 4949 4700) //level 2 & 4 #pragma warning (error : 4200) // level 3 & 4 #pragma warning (error : 4244) // nolevel: #pragma warning (error : 4335 4368 4394 4430 4439 4484 4485 4687 4693 4694 4801 4867) // level 1 #pragma warning (error : 4002 4003 4005 4006 4010 4015 4020 4022 4024 4025 4026 4027 4028 4029 4030 4031 4033 4034 4036 4038 4041 4042 4045 4047 4048 4049 4052 4054 4055 4067 4068 4074 4075 4076 4077 4079 4080 4081 4083 4085 4086 4087 4088 4089 4090 4091 4096 4097 4098 4103 4109 4113 4114 4116 4117 4119 4120 4122 4124 4129 4137 4138 4141 4142 4143 4144 4145 4153 4154 4155 4157 4158 4160 4162 4163 4164 4165 4166 4167 4168 4172 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4185 4186 4187 4190 4215 4216 4218 4224 4226 4227 4228 4229 4230 4237 4251 4258 4264 4269 4272 4273 4276 4286 4288 4291 4293 4297 4303 4305 4311 4312 4313 4318 4319 4325 4326 4329 4333 4340 4342 4344 4346 4348 4350 4351 4353 4358 4364 4369 4374 4375 4376 4377 4378 4379 4381 4382 4383 4384 4391 4392 4393 4395 4397 4399 4401 4402 4403 4405 4406 4407 4409 4410 4411 4420 4440 4441 4445 4461 4470 4482 4486 4488 4489 4490 4502 4503 4506 4508 4518 4519 4526 4530 4532 4533 4537 4539 4540 4541 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4555 4556 4558 4561 4566 4572 4581 4584 4600 4602 4606 4612 4613 4615 4616 4618 4620 4621 4624 4628 4630 4631 4632 4650 4651 4652 4655 4656 4657 4659 4661 4662 4667 4669 4674 4677 4678 4679 4683 4684 4685 4688 4691 4692 4711 4715 4716 4717 4722 4727 4729 4730 4731 4733 4734 4739 4742 4743 4744 4747 4772 4788 4789 4794 4799 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4817 4819 4821 4822 4829 4832 4835 4836 4900 4905 4906 4912 4917 4920 4925 4926 4927 4928 4929 4930 4935 4939 4944 4945 4946 4947 4951 4952 4953 4955 4964 4965 4997 4999) // level 2 #pragma warning (error : 4007 4051 4056 4094 4099 4146 4150 4156 4244 4250 4275 4285 4302 4307 4308 4309 4345 4356 4412 4653 4756 4826 4948) // level 3 #pragma warning (error : 4013 4018 4023 4060 4062 4065 4066 4069 4073 4101 4102 4133 4159 4161 4191 4192 4197 4231 4240 4243 4265 4267 4278 4280 4281 4282 4283 4287 4290 4306 4310 4334 4341 4357 4359 4390 4398 4404 4414 4509 4511 4520 4521 4522 4523 4534 4535 4538 4543 4554 4557 4570 4580 4608 4619 4622 4633 4635 4636 4637 4638 4640 4641 4645 4646 4686 4723 4724 4738 4748 4792 4800 4823 4980 4995 4996) // level 4 #pragma warning (error : 4001 4019 4032 4053 4057 4061 4063 4064 4092 4100 4121 4125 4127 4130 4131 4132 4152 4189 4201 4202 4203 4204 4205 4206 4207 4208 4210 4211 4212 4213 4214 4220 4221 4232 4233 4234 4235 4238 4239 4242 4245 4254 4255 4256 4263 4266 4268 4289 4295 4296 4324 4336 4337 4339 4343 4347 4365 4366 4389 4400 4408 4428 4429 4431 4432 4433 4434 4460 4480 4481 4487 4505 4510 4512 4513 4514 4515 4516 4517 4536 4559 4564 4565 4571 4610 4611 4623 4625 4626 4629 4634 4639 4668 4670 4672 4673 4680 4681 4682 4690 4701 4702 4706 4709 4710 4714 4718 4725 4740 4764 4815 4816 4820 4913 4918 4931 4932 4937 4938 4960)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With