Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disable Compiler Waring

284 views
Skip to first unread message

Ashutosh Bhawasinka

unread,
May 27, 2008, 1:10:08 AM5/27/08
to
Hi,
I want to disable compiler warning C4482 (nonstandard extension used:
enum 'enum' used in qualified name)

I can disable the warning using this,

#pragma warning(push)
#pragma warning(disable : 4482)

//My code here

#pragma warning(pop)


But this is just for a single file. How can I disable this error at the
project level?? I guess there are some compiler switch for it.


Secondly, will this have any effect on the project?

Regards,
Ashutosh

Carl Daniel [VC++ MVP]

unread,
May 27, 2008, 2:05:51 AM5/27/08
to
Ashutosh Bhawasinka wrote:
> Hi,
> I want to disable compiler warning C4482 (nonstandard extension used:
> enum 'enum' used in qualified name)
>
> I can disable the warning using this,
>
> #pragma warning(push)
> #pragma warning(disable : 4482)
>
> //My code here
>
> #pragma warning(pop)
>
>
> But this is just for a single file. How can I disable this error at
> the project level?? I guess there are some compiler switch for it.

/wd4482 on the compiler command line will disable that warning. Try typing
cl /? at a "visual studio" command prompt to see all the compiler command
line options.

> Secondly, will this have any effect on the project?

Other than suppressing the warning, no.

-cd


Jialiang Ge [MSFT]

unread,
May 27, 2008, 2:10:23 AM5/27/08
to
Hello Ashutosh,

Suppose that you are using Visual Studio 2005 to build the VC project. In
order to disable some warning message in the project level, the steps are
as follows:

1. Right click on the project in Solution Explorer, and select "Property"
2. Go to "Configuration Properties" | "C/C++" | "Advanced" | "Disable
Specific Warnings"
3. In the "Disable Specific Warnings" dialog, input the warning ID. The ID
is just numeric part, in our case, it's 4482.
4. Click OK, and re-compile the project.

The setting is saved in your vcproj file:

<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTDLL_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4482"
/>

This setting won't have any effect but removing 4822 from warning lists
from the project.

Please have a try and let me know whether this works for you.

Regards,
Jialiang Ge (jia...@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Ulrich Eckhardt

unread,
May 27, 2008, 2:56:50 AM5/27/08
to
Ashutosh Bhawasinka wrote:
> I want to disable compiler warning C4482 (nonstandard extension used:
> enum 'enum' used in qualified name)

Fix the code:

enum foo { bar };
// wrong
foo f = foo::bar;
// correct
foo f = bar;

Enumeration constants 'leak' into the surrounding namespace. If you don't
want that, enclose the enumeration itself in a namespace:

namespace foo {
enum type { bar };
}
foo::type f = foo::bar;

> Secondly, will this have any effect on the project?

Disabling or ignoring warning doesn't directly affect the outcome, but in
general warnings are a sign of low code quality. Your code above is simply
not portable to other compilers that don't support this extension.

Fix it, it's broken.

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

Ashutosh Bhawasinka

unread,
May 27, 2008, 3:21:17 AM5/27/08
to
Thanks everyone!

Ashutosh

unread,
May 27, 2008, 6:55:27 AM5/27/08
to
HI Ulrich,
I don't have to worry about compiling my code in other compiler. But I
like your idea of putting/enclosing the enum declaration in a namespace.

Thanks & Regards,
Ashutosh

0 new messages