FP / C:S978: Argument name detected as reserved name

In a C project/code, I have the line:

typedef void MyFunction( Message* _message );

SonarCloud raises a S978 issue because of _message .
I don’t see why this name should be considered as a reserved name: it has only one underscore, and its first letter is in lowercase.

Thanks for your report.

Identifiers in the global namespace with a starting with a (single) underscore are reserved names. Is this typdefin the global namespace?

If it is not can you share a reproducer? Please let me know it you can’t share the reproducer publicly, then I’ll contact you with a DM.

Hello,

_message is not in global namespace. It is in the function scope.

I created a reproducer

#include <string.h>

struct S{ int i; };

// Raises S978:Change the reserved name "_global" to a non-reserved one.
// Raises S978:Change the reserved name "_g" to a non-reserved one.
typedef void(*_g)(struct S _global);

void bar() {
  // Raises S978:Change the reserved name "_function" to a non-reserved one.
  typedef void(*_f)(struct S _function);
  ...
}

I did a bit more investigation in the C and C++ standard. Based on that investigation it seems both _global and _function are not in the global namespace. So my initial response was wrong; _message is not in the global namespace.

I’ve created a ticket to address this issue.

OK, thank you !