Skip to content

MISRA23_8.8 flagging static class member #101

@kylejacksonb

Description

@kylejacksonb

Code snippet and violation:

header.h

class MY_CLASS
{
private:
    static bool sm_LoggingEnabled;
};

header.cpp

#include "header.h"
bool MY_CLASS::sm_LoggingEnabled = false;

Violation raised:
8.8 The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

If I add static in cpp the GCC compiler shows this warning:
warning: 'static' may not be used when defining (as opposed to declaring) a static data member [-fpermissive]

We cannot use inline as we are using C+11.

@kennethctdmn Since this is a C only check, let's just ignore classes.

Metadata

Metadata

No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions