Warning on useless 'const' in a function declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all:

Sometimes, I forget to remove useless 'const' modifiers in function declarations. A simplified example is:

file.h:

int f ( const int a );  // 'const' is useless here.


file.cpp:

int f ( const int a )
{
  return a;
}


Is there a way to make GCC issue warnings about those useless 'const' modifiers? At the very least, it would save some head scratching during code reviews.

Apparently, clang-tidy has option 'readability-avoid-const-params-in-decls' for such a warning:

https://clang.llvm.org/extra/clang-tidy/checks/readability/avoid-const-params-in-decls.html

Thanks in advance,
  rdiez



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux