If you are building /W3 and still getting the warnings, options include:
1) Don't name the parameter, simply use the type in the parameter list
like this:
MyClass::MyMethod(int /*unused integer*/, double thisOneIsUsed)
{....}
Unfortunately this confuses Doxygen so I don't use it often.
2) For MSVC:
#ifdef _MSC_VER
#pragma warning(disable:4100)
#endif
3) Use the UNREFERENCED_PARAMETER macro or an equivalent portable
version of this macro (There is one in ACE)
Unfortunately in my opinion this clutters the code with distracting
information. When you are looking at a method trying to figure out
what it does, the fact that it doesn't use one of the parameters is
rarely of interest.
I'll consider adding #2 to the QuickFAST precompiled headers.
Dale
> --
> You received this message because you are subscribed to the Google
> Groups "quickfast_users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/quickfast_users/-/xOzoyNdtsu8J.
> To post to this group, send email to quickfa...@googlegroups.com.
> To unsubscribe from this group, send email to
> quickfast_use...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/quickfast_users?hl=en.
--
Dale Wilson
Principal Software Engineer
Object Computing, Inc.
I'll be checking in the few changes it took to eliminate the level 4
warnings.
However, my solution to the problem you are seeing was to add this line
to QuickFAST_pch.h
#pragma warning(disable:4100) // Disable: unreferenced formal parameter
(/W4 warning)
In my opinion, unused formal parameters are quite common and perfectly
acceptable in virtual methods, and any effort to eliminate them in-place
tends to introduce confusing distractions.
Dale
#include <Application/QuickFAST.h>
This picks up all of the prerequisites needed by QuickFAST code
including the #pragmas, the boost includes, etc. then loads the
QuickFAST header files commonly needed by applications.
This would be a good thing to put in a precompiled header file for your
application.
If you attempt to include QuickFAST header files piecemeal you will run
into the problem you are describing. I have recently added compile-time
checking in the header files to warn about this, but I need to add
additional documentation to make it more obvious.
To answer your "Why?" question:
Having each header include boost, etc. and specify any appropriate
#pragma tends to defeat the purpose of precompiled headers (not to
mention cluttering the files and being a maintenance nightmare.)
Microsoft has the #pragma once which solves the problem for MSVC builds,
but with other compilers even if the included file has an include guard
symbol (which most do) the compiler has to open and parse the files to
find the matching #if/#endif pairs -- noticeably increasing compile time.
Dale
> are used by the library itself. Why is this the way it is? --
> You received this message because you are subscribed to the Google
> Groups "quickfast_users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/quickfast_users/-/d5ePly3lojAJ.
> To post to this group, send email to quickfa...@googlegroups.com.
> To unsubscribe from this group, send email to
> quickfast_use...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/quickfast_users?hl=en.
Maybe it's already the case, but please use pragma push/pop when changing warning levels in the headers.
Not doing so can impact users of the header, for example:
// Visual Studio
#pragma warning(push)
#pragma warning(disable : 4303) // old-style-cast
int floor(const double value) { return (int)value; }
#pragma warning(pop)
// GCC 4.5 - must disable for remainder of compilation unit or manually re-enable it
#pragma GCC diagnostic ignored "-Wold-style-cast"
int floor(const double value) { return (int)value; }
#pragma GCC diagnostic warning "-Wold-style-cast"
// GCC >= 4.6
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
int floor(const double value) { return (int)value; }
#pragma GCC diagnostic pop
I'm not suggesting to allow old-style-cast above, it's simply an easy example.
Thanks,
Jason Aubrey
________________________________________
From: quickfa...@googlegroups.com [quickfa...@googlegroups.com] On Behalf Of Dale Wilson [wil...@ociweb.com]
Sent: Wednesday, December 07, 2011 10:46 AM
To: quickfa...@googlegroups.com
Subject: Re: [quickfast_users] unreferenced formal parameter warnings in QuickFast
Dale
--
You received this message because you are subscribed to the Google Groups "quickfast_users" group.
I already used push & pop which changing the warning levels for special
case code, but I had not considered doing so for the warnings that
QuickFAST disables "globally"
I have added the appropriate warning push & pop to Application/QuickFAST.h