CPP:s831 False positive for GCC builtin's

Error: Objects or functions with external linkage shall be declared in a header file

code that triggered it:

count += __builtin_popcount(current); 

So it is generating an error for the GCC builtin functions which don’t have header files and cant be declared in header files because they are part of the compiler implementation.

Hello @AndrewGoedhart and welcome to our community!

Thanks for reporting this false positive.
I could not reproduce the issue with just this line of code so I’ll need you to create a reproducer.
First can you tell me on which product you encounter this false positive (SonarLint, SonarQube, SonarCloud)?