Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > MSVC sillywarnings -- more?

Reply
Thread Tools

MSVC sillywarnings -- more?

 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      02-23-2010
I just added MSVC sillywarnings to this list as I encountered them.

Are there more that should be added?

Note: "unreferenced" warnings are handled by other explicit mechanism.


<code>
// Copyright (c) Alf P. Steinbach, 2010.
// #include <progrock/cppx/compiler_specific/msvc/no_sillywarnings_please.h>

#ifndef PROGROCK_CPPX_COMPILERSPECIFIC_MSVC_NOSILLYWARNING SPLEASE_H
#define PROGROCK_CPPX_COMPILERSPECIFIC_MSVC_NOSILLYWARNING SPLEASE_H


#ifndef _MSC_VER
# error This file is specific to the MSVC (Microsoft Visual C++) compiler.
#endif

#pragma warning( disable: 4061 ) // enum value is not *explicitly* handled in
switch
#pragma warning( disable: 4217 ) // member template isn't copy constructor
#pragma warning( disable: 4250 ) // inherits (implements) some member via
dominance
#pragma warning( disable: 4347 ) // "behavior change", function called
instead of template
#pragma warning( disable: 4355 ) // "'this': used in member initializer list
#pragma warning( disable: 4505 ) // unreferenced function has been removed
#pragma warning( disable: 4510 ) // default constructor could not be generated
#pragma warning( disable: 4511 ) // copy constructor could not be generated
#pragma warning( disable: 4512 ) // assignment operator could not be generated
#pragma warning( disable: 4513 ) // destructor could not be generated
#pragma warning( disable: 4623 ) // default constructor could not be generated
#pragma warning( disable: 4624 ) // destructor could not be generated
#pragma warning( disable: 4625 ) // copy constructor could not be generated
#pragma warning( disable: 4626 ) // assignment operator could not be generated
#pragma warning( disable: 4640 ) // a local static object is not thread-safe
#pragma warning( disable: 4670 ) // a base class of an exception class is
inaccessible for catch
#pragma warning( disable: 4672 ) // a base class of an exception class is
ambiguous for catch
#pragma warning( disable: 4673 ) // a base class of an exception class is
inaccessible for catch
#pragma warning( disable: 4675 ) // resolved overload was found by
argument-dependent lookup
#pragma warning( disable: 4702 ) // unreachable code, e.g. in <list> header.
#pragma warning( disable: 4710 ) // call was not inlined
#pragma warning( disable: 4711 ) // call was inlined
#pragma warning( disable: 4820 ) // some padding was added
#pragma warning( disable: 4917 ) // a GUID can only be associated with a
class, interface or namespace

// The following are real warnings but are generated by almost all MS headers,
including
// standard library headers, so it's impractical to leave them on.
#pragma warning( disable: 4619 ) // there is no warning number 'XXXX'
#pragma warning( disable: 4668 ) // XXX is not defined as a preprocessor macro


#endif
</code>


Cheers,

- Alf
 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      02-23-2010
On Feb 23, 2:02*am, "Alf P. Steinbach" <al...@start.no> wrote:
> I just added MSVC sillywarnings to this list as I encountered them.
>
> Are there more that should be added?
>


> #ifndef _MSC_VER
> # * error This file is specific to the MSVC (Microsoft Visual C++) compiler.
> #endif


Is there a reason you #error if it isn't MSVC? Why not just bypass
all the #pragmas
for non-VC code?
 
Reply With Quote
 
 
 
 
Noah Roberts
Guest
Posts: n/a
 
      02-23-2010
In article <hm093t$974$>,
says...
>
> I just added MSVC sillywarnings to this list as I encountered them.
>
> Are there more that should be added?
>
> Note: "unreferenced" warnings are handled by other explicit mechanism.
>
>
> <code>
> // Copyright (c) Alf P. Steinbach, 2010.
> // #include <progrock/cppx/compiler_specific/msvc/no_sillywarnings_please.h>
>
> #ifndef PROGROCK_CPPX_COMPILERSPECIFIC_MSVC_NOSILLYWARNING SPLEASE_H
> #define PROGROCK_CPPX_COMPILERSPECIFIC_MSVC_NOSILLYWARNING SPLEASE_H


I'd add the macro's that ruin the stupid deprecation warnings:
#define _CRT_SECURE_NO_DEPRECATE

There's also 4099 - type name first seen using 'struct' now seen using
'class' - or visa versa.



--
http://crazyeddiecpp.blogspot.com
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      02-23-2010
* red floyd:
> On Feb 23, 2:02 am, "Alf P. Steinbach" <al...@start.no> wrote:
>> I just added MSVC sillywarnings to this list as I encountered them.
>>
>> Are there more that should be added?
>>

>
>> #ifndef _MSC_VER
>> # error This file is specific to the MSVC (Microsoft Visual C++) compiler.
>> #endif

>
> Is there a reason you #error if it isn't MSVC? Why not just bypass
> all the #pragmas
> for non-VC code?


I feel the code gets too complex if different compilers and OS'es and versions
of libraries etc. are supported in the same file.

As I recall some files in Boost mix this up, special-casing this and that via
preprocessor directives in the middle of files, and anyway I felt I'd had enough
of that.

Practically it cannot be avoided to make the decision somewhere, but I feel it's
more clean if that decision is separated from implementation of functionality.


Cheers,

- Alf
 
Reply With Quote
 
Noah Roberts
Guest
Posts: n/a
 
      02-23-2010
In article <hm093t$974$>,
says...
>
> I just added MSVC sillywarnings to this list as I encountered them.
>
> Are there more that should be added?
>
> Note: "unreferenced" warnings are handled by other explicit mechanism.


> #pragma warning( disable: 4505 ) // unreferenced function has been
> removed


I'm actually having trouble with a program that generates this warning,
and it's the first time I've ever seen the warning. See my thread on MI
& clone().

--
http://crazyeddiecpp.blogspot.com
 
Reply With Quote
 
Krice
Guest
Posts: n/a
 
      02-24-2010
On 23 helmi, 12:02, "Alf P. Steinbach" <al...@start.no> wrote:
> Are there more that should be added?


Warning for silly programmers.
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      02-25-2010
* Alf P. Steinbach:
> I just added MSVC sillywarnings to this list as I encountered them.
>
> Are there more that should be added?
>
> Note: "unreferenced" warnings are handled by other explicit mechanism.


I've now added the following:

4127 // conditional expression is constant
4661 // Juha Nieminen| a member of the template class is not defined
4099 // Noah Roberts| first seen using 'struct' now seen using 'class'
4251 // Paavo Helde| needs to have dll-interface to be used by clients
4275 // Paavo Helde| exported class derived from non-exported class

So, for those who perhaps want the list so as to transform MSVC into something
reasonable (quite a lot of code now compiles cleanly at warning level 4!),


<code>
#pragma warning( disable: 4061 ) // enum value is not *explicitly* handled in
switch
#pragma warning( disable: 4099 ) // first seen using 'struct' now seen using
'class'
#pragma warning( disable: 4127 ) // conditional expression is constant
#pragma warning( disable: 4217 ) // member template isn't copy constructor
#pragma warning( disable: 4250 ) // inherits (implements) some member via
dominance
#pragma warning( disable: 4251 ) // needs to have dll-interface to be used by
clients
#pragma warning( disable: 4275 ) // exported class derived from non-exported
class
#pragma warning( disable: 4347 ) // "behavior change", function called
instead of template
#pragma warning( disable: 4355 ) // "'this': used in member initializer list
#pragma warning( disable: 4505 ) // unreferenced function has been removed
#pragma warning( disable: 4510 ) // default constructor could not be generated
#pragma warning( disable: 4511 ) // copy constructor could not be generated
#pragma warning( disable: 4512 ) // assignment operator could not be generated
#pragma warning( disable: 4513 ) // destructor could not be generated
#pragma warning( disable: 4623 ) // default constructor could not be generated
#pragma warning( disable: 4624 ) // destructor could not be generated
#pragma warning( disable: 4625 ) // copy constructor could not be generated
#pragma warning( disable: 4626 ) // assignment operator could not be generated
#pragma warning( disable: 4640 ) // a local static object is not thread-safe
#pragma warning( disable: 4661 ) // a member of the template class is not
defined.
#pragma warning( disable: 4670 ) // a base class of an exception class is
inaccessible for catch
#pragma warning( disable: 4672 ) // a base class of an exception class is
ambiguous for catch
#pragma warning( disable: 4673 ) // a base class of an exception class is
inaccessible for catch
#pragma warning( disable: 4675 ) // resolved overload was found by
argument-dependent lookup
#pragma warning( disable: 4702 ) // unreachable code, e.g. in <list> header.
#pragma warning( disable: 4710 ) // call was not inlined
#pragma warning( disable: 4711 ) // call was inlined
#pragma warning( disable: 4820 ) // some padding was added
#pragma warning( disable: 4917 ) // a GUID can only be associated with a
class, interface or namespace

// The following are real warnings but are generated by almost all MS headers,
including
// standard library headers, so it's impractical to leave them on.
#pragma warning( disable: 4619 ) // there is no warning number 'XXXX'
#pragma warning( disable: 4668 ) // XXX is not defined as a preprocessor macro
</code>


Cheers,

- Alf
 
Reply With Quote
 
Balog Pal
Guest
Posts: n/a
 
      02-26-2010

"Alf P. Steinbach" <>

> 4127 // conditional expression is constant


That is not silly at all, and do catch mistakes -- though too bad it can't
guess where we used a constant intentionally...

> 4099 // Noah Roberts| first seen using 'struct' now seen using 'class'


Some versions create different names for class/struct so ignoring this may
lead to cryptic linker errors...

My tuning file looks like below. I normally compile at W3 switching to W4
only occasionally. So most tuning is actually to elevate levels...


- ----------
// this file rearranges the default levels of warning messages
#pragma warning(2:4032) // function arg has different type from
declaration
#pragma warning(2:4092) // 'sizeof' value too big
#pragma warning(2:4132 426// const object not initialized
#pragma warning(2:4152) // pointer conversion between function and data
#pragma warning(error:4239) // standard doesn't allow this conversion
#pragma warning(error:4172) // returning address of local variable or
temporary
#pragma warning(1:4701 4700) // local variable used without being
initialized
#pragma warning(2:4706) // if (a=b) instead of (if a==b)
#pragma warning(2:4709) // comma in array subscript
#pragma warning(2:4061) // not all enum values tested in switch
statement
#pragma warning(4:4710) // inline function was not inlined
#pragma warning(1:4121) // space added for structure alignment
#pragma warning(disable:4505) // unreferenced local function removed
#pragma warning(3:4019) // empty statement at global scope
#pragma warning(3:4057) // pointers refer to different base types
#pragma warning(3:4125) // decimal digit terminates octal escape
#pragma warning(2:4131) // old-style function declarator
#pragma warning(3:4211) // extern redefined as static
#pragma warning(4:4213) // cast on left side of = is non-standard
#pragma warning(1:4222) // member function at file scope shouldn't be
static
#pragma warning(error:4234 4235)// keyword not supported or reserved for
future
#pragma warning(3:4504) // type ambiguous; simplify code
#pragma warning(3:4507) // explicit linkage specified after default
linkage
#pragma warning(1:4515) // namespace uses itself
#pragma warning(3:4516 4517)// access declarations are deprecated
#pragma warning(3:4670) // base class of thrown object is inaccessible
#pragma warning(3:4671) // copy ctor of thrown object is inaccessible
#pragma warning(3:4673) // thrown object cannot be handled in catch
block
#pragma warning(3:4674) // dtor of thrown object is inaccessible
#pragma warning(error:4705) // statement has no effect (example: a+1

#pragma warning(disable:4786) // identifier was truncated to 'number'
characters in the debug information

#pragma warning(3:4727) // conditional expression is constant
#pragma warning(error:450 // function should return a value; void return
type assumed

#pragma warning(3:4239) //nonstandard extension used : 'token' : conversion
from 'type' to 'type'
#pragma warning(error:4146) //unary minus operator applied to unsigned type,
result still unsigned
#pragma warning(1:4132) //'object' : const object should be initialized

#pragma warning(1:423 //nonstandard extension used : class rvalue used as
lvalue

#pragma warning (disable:4097) //'typedef-name 'tParent' used as synonym for
class-name 'IdxArr<struct tabdef>'
#pragma warning (disable:4710) //function not expanded
#pragma warning (disable:4711) //function 'function' selected for inline
expansion


#ifdef _DEBUG
#pragma warning(4:4800) //forcing bool variable to one or zero, possible
performance loss
#else
#pragma warning(disable:4800) //forcing bool variable to one or zero,
possible performance loss
#pragma warning(disable:4100) //unreferenced formal parameter
#endif

#pragma warning(disable:4290) //C++ exception specification ignored

 
Reply With Quote
 
Balog Pal
Guest
Posts: n/a
 
      02-26-2010
"Pete Becker" <>
>>> 4099 // Noah Roberts| first seen using 'struct' now seen using
>>> 'class'

>>
>> Some versions create different names for class/struct so ignoring this
>> may lead to cryptic linker errors...
>>

>
> So the warning is telling you that the compiler has done something that is
> not allowed by the language definition.


Yeah :-/

It is still better than doing it in the dark.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
diff between pc-msvc pc-cygwin and svg-GDI - which is fastest vc Firefox 10 02-28-2004 01:05 AM
MSVC 4.2 needed Trent WADDINGTON C++ 4 09-30-2003 02:26 AM
MSVC 6.0 -- LNK1179(duplicate comdat) problem Arkadiy Vertleyb C++ 1 07-09-2003 03:54 PM
Re: array of complex numbers in MSVC++ 6 Victor Bazarov C++ 0 07-05-2003 02:57 PM
Problem Compiling Xerces-C 2.3 with MSVC.Net 7.1 Dan XML 0 07-01-2003 11:57 AM



Advertisments