Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making constants in MISRA compliant C++
#2
I've been faced with the same issue and I choosed kinda 3):

public header:
Code:
enum SIZES
{
    ...,
    MAX_USER_NAME = 64U,
    MAX_GROUP_NAME_ = 32U,
    MAX_USERS = 256U,
    ...
};
// Note: This does not violate any rules, especially not the ODR!

module:
Code:
void myFunc()
{
    ...
    char_t userList[ MAX_USERS ][ MAX_USER_NAME ];
    // IMHO this does NOT violate 4-5-2. LDRA is known for some false positives.
    
    for ( size_t idx = 0U; idx < static_cast( MAX_USERS ); idx++ )
    {
        userList[ idx ][ 0U ] = '\0';
    }
   ...
}

Anybody any idea about this?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)