Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: GCC warnings  (Read 6568 times)

0 Members and 1 Guest are viewing this topic.

TheWaffle

    Topic Starter


    Hopeful
  • Thanked: 4
    • Yes
  • Computer: Specs
  • Experience: Beginner
  • OS: Linux variant
GCC warnings
« on: November 29, 2018, 03:37:55 AM »
I am playing with GCC's warnings, and I haven't been able to figure out how to suppress some of them.

The most annoying warning I enabled is with -Wshadow.
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

I learned this pattern:
Code: [Select]
Person::Person(string name)
{
this->name = name;
My shadowing in the constructor is intentional. I do this a lot.  Is there a way to suppress the warning:
Quote
declaration of ‘name’ shadows a member of ‘Person’
on a case by case basis? Maybe with a macro? How do you guys do it?
I know a lot of people would do something like
Code: [Select]
this->myName = namebut I find the extra 'my' cringy. I don't know why I don't like it. I just don't.

nil

  • Global Moderator


  • Intermediate
  • Thanked: 15
    • Experience: Experienced
    • OS: Linux variant
    Re: GCC warnings
    « Reply #1 on: November 29, 2018, 06:15:28 AM »
    rules for Wshadow have been changing in response to complaints from devs -

    https://stackoverflow.com/a/15554949
    Do not communicate by sharing memory; instead, share memory by communicating.

    --Effective Go