cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

Add --macro-file option to parse and apply multiple #define directives

Open mishabunte opened this issue 1 year ago • 3 comments

I have several macro files in my project that are included via the -imacro option. To enhance flexibility, I added support for adding custom defines from a file to the build flow.

Example usage:

  --macro-file=defines.h

will produce this user defines

Defines: CONFIG_GPIO=1;CONFIG_ADC_INIT_PRIORITY=50;CONFIG_GPIO_INIT_PRIORITY=40;CONFIG_SRAM_SIZE=446;

defines.h contents:

#define CONFIG_GPIO 1
#define CONFIG_ADC_INIT_PRIORITY 50
#define CONFIG_GPIO_INIT_PRIORITY 40
#define CONFIG_SRAM_SIZE 446

mishabunte avatar Oct 18 '24 17:10 mishabunte

Thanks for your contribution.

This needs tests added to TestCmdLineParser. But I have almost the same changes in a local branch which already includes the tests among with some refactorings and slightly cleaner code: https://github.com/firewave/cppcheck/tree/def-param.

firewave avatar Oct 18 '24 17:10 firewave

Both changesets also lack the documentation in the CLI and manpage.

firewave avatar Oct 18 '24 17:10 firewave

This should also be used to fix a TODO in tools/defines/run_cppcheck.sh - that's the case I intended the option for.

firewave avatar Oct 18 '24 17:10 firewave

how is this different from --include option.

danmar avatar Oct 26 '24 18:10 danmar