I suggest you ...

Having multiple initializer functions in a constructor

Lint checks, if all of the members are initialized in the constructor. Optionally this check could be redirected to an initializer-function introduced with the -sem Command. But then the initialization has to be done completely in the initializer-function.

In our embedded software it is quite common to have more than one function doing the initialization task, e.g.:

class A
{
public:
A()
{
member_a = 0;
initFunction1();
initFunction2();
}
private:
void initFunction1()
{
member_b = 0;
}

void initFunction2()
{
member_c = 0;
}

int member_a;
int member_b;
int member_c;
};

It would be very helpful, that lint supports this way of doing initializations.

19 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Armin shared this idea  ·   ·  Admin →

    In the upcoming PC-lint Plus, full or partial initializations that takes place in functions called by a constructor are automatically recognized without the need for an initializer semantic. In the example provided, no message would be issued. The initializer semantic can still be used if the definition of an initializing member function is not available but otherwise isn’t necessary.

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Catoblepa commented  · 

        We have exactly the same problem in our project: initializations are organized in several methods, since parts of the initializtions are also needed later after construction.
        In the end we found no better solution than disabling the warning 1565 at all for the affected classes - too bad.

      Feedback and Knowledge Base