In .h file I have a persistent variable
extern <Enum Datatype> __attribute__((section(".persist"))) state
In .c file I have to initialize the variable state to one of the member of enum
Example:
enum state = <One of the member of enum>
If I try the above method the compiler throws the warning persistent variables cannot be initialized.
Note: The persistent variable is used for a test of PRE and POST usage of a system, hence initially in the application code I want the test to start from PRE.
I have been referring to this link, where it clearly says the following statement.
Another useful link would be this, where it says that
In summary, persistent variable should not be initialized.
There is a code snippet available in the above link, where it says how to 'safely initialize' the
persistentvariable. Just pasting the same here for easy reference.Hope it helps you.