The usual builtin checkers in cppcheck does not have access to preprocessor directives and can't check this directly. So well if we implement this we either have to use an addon or we have to make sure the builtin checkers will have the information also.
For information , autosar guideline m16-2-3 says "Include guards shall be provided." and this rule is provided in Cppcheck Premium. However as I read it m16-2-3 does not allow #pragma once therefore that checker will write a warning even if that is used.
Last edit: Daniel Marjamäki 2024-05-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Something that would detect a missing #pragma once or #ifndef guard.
Good idea.
See https://trac.cppcheck.net/ticket/2829
The usual builtin checkers in cppcheck does not have access to preprocessor directives and can't check this directly. So well if we implement this we either have to use an addon or we have to make sure the builtin checkers will have the information also.
For information , autosar guideline m16-2-3 says "Include guards shall be provided." and this rule is provided in Cppcheck Premium. However as I read it m16-2-3 does not allow
#pragma once
therefore that checker will write a warning even if that is used.Last edit: Daniel Marjamäki 2024-05-30