The Artima Developer Community
Sponsored Link

Articles Forum
C++ Coding Standards

1 reply on 1 page. Most recent reply: Nov 19, 2004 9:09 PM by Matthew Wilson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Chuck Allison

Posts: 63
Nickname: cda
Registered: Feb, 2003

C++ Coding Standards Posted: Nov 19, 2004 3:00 PM
Reply to this message Reply
Advertisement
Two leading C++ experts present hard-won wisdom for the entire C++ development experience.

Read this excerpt form their new book:

http://www.artima.com/cppsource/codestandards.html


Matthew Wilson

Posts: 145
Nickname: bigboy
Registered: Jun, 2004

Re: C++ Coding Standards Posted: Nov 19, 2004 9:09 PM
Reply to this message Reply
Guys

As I mentioned in the review phase, I disagree with the monotonicity of the unused parameter item. I can now avail myself of the underhanded option of repeating myself in this public forum, and I find myself unable to resist. ;)

Many developers are diligently using automatic documentation tools, which can be stymied by an anonymous function parameter, and produce warnings of their absence. Since documentation tools may form an important part of an automated build process, it behooves us to get no warnings in that phase, as in any other. Hence, I believe the best, although perhaps not the most beautiful, approach is to do the following:


/// \param name Blah blah blah name blah blah
/// \param code Blah blah blah code blah blah
int func1(char const *name, int code = 0)
{
STLSOFT_SUPPRESS_UNUSED(code); // or whatever your macro of choice may be



... // Use "name" and do our stuff ...
}


In this way, we placate the compiler and the documentation generator, and also provide what I'd argue is a more obvious mnemonic to maintainers of the code that we know the argument is unused and we're ok with that.

:-)

Matthew

Flat View: This topic has 1 reply on 1 page
Topic: Reducing Preprocessor Namespace Pollution Previous Topic   Next Topic Topic: Design by Contract

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use