This is another AVR problem. I have some old library code which pulls in various register writes depending on which registers are defined in the particular micro's I/O definitions file.
#ifdefEEARLoutb(EEARL,addr); // warning
#endifoutb(EEDR,data); // no warning
I don't really understand why this is an error when the line with EEDR does not generate an error. Neither of those symbols is defined. If I provide the path to the AVR library headers then the error goes away, but analysis is very slow as they are pretty complex headers.
I get the same sort of errors when comparing with a constant within #ifdef.
#ifdefEEP_SHADOW_TOPif(addr<EEP_SHADOW_TOP)do_this(); // warningelseif(addr<SOME_UNDEFINED_VALUE)do_that(); // no warning
#endif
I can silence them by setting an explicit definition, but I'm curious as to why this only raises a warning for the #ifdef case and not for general undefined symbols.
Skipping configuration 'EEARH;EEARL' since the value of 'EEARH' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
By default Cppcheck tries to guess configurations and check all code. It wants to check the code inside the #ifdef. But there is no way for Cppcheck to guess what it should tell the preprocessor that EEARL is. It must tell the preprocessor what EEARL is to check the code inside the #ifdef if it doesn't then the preprocessor will remove the code.
Cppcheck does not tell the preprocessor what EEDR is.. so that will just be kept as is by the preprocessor.
As the warnings say; you can fix these warnings either with -D or -U. Ignore them if you don't care that the code is not checked.
Last edit: Daniel Marjamäki 2020-07-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is another AVR problem. I have some old library code which pulls in various register writes depending on which registers are defined in the particular micro's I/O definitions file.
I don't really understand why this is an error when the line with EEDR does not generate an error. Neither of those symbols is defined. If I provide the path to the AVR library headers then the error goes away, but analysis is very slow as they are pretty complex headers.
I get the same sort of errors when comparing with a constant within #ifdef.
I can silence them by setting an explicit definition, but I'm curious as to why this only raises a warning for the #ifdef case and not for general undefined symbols.
Do you mean such warnings:
Skipping configuration 'EEARH;EEARL' since the value of 'EEARH' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
By default Cppcheck tries to guess configurations and check all code. It wants to check the code inside the
#ifdef
. But there is no way for Cppcheck to guess what it should tell the preprocessor that EEARL is. It must tell the preprocessor what EEARL is to check the code inside the#ifdef
if it doesn't then the preprocessor will remove the code.Cppcheck does not tell the preprocessor what EEDR is.. so that will just be kept as is by the preprocessor.
As the warnings say; you can fix these warnings either with
-D
or-U
. Ignore them if you don't care that the code is not checked.Last edit: Daniel Marjamäki 2020-07-15