0

In the following code I'm trying to make "SRAM", "FRAM", "EEPROM", and "FLASH" constants, MEM_TYPE an 8-bit variable that can be changed by other programs. The pointer should be pointing to MEM_TYPE.
I'm getting a error under uint8_t (defined as BYTE elsewhere in an included file), "*", *and enum which is causing the rest to be errored as well. I copied the format of another's program that I can't post here.
What am I really doing? And how do I fix it?

uint8_t volatile * const enum
    {
        SRAM,
        FRAM,
        EEPROM,
        FLASH
     }MEM_TYPE;
2
Contributors
1
Reply
30
Views
2 Years
Discussion Span
Last Post by Nutster
2

You are mixing your types. Let's do this in two steps.

enum mem_types
{
    SRAM,
    FRAM,
    EEPROM,
    FLASH
};

enum mem_types volatile *MEM_TYPE = NULL;

An enum is a list of constants, so there is no need for the const; in fact, it gets in the way. You then specify the volatile pointer. Pointers need to know what type they are pointing at, in this case, a specific enum. You can not mix your types in this way. The compiler may optimize your pointer down to 8 bits, but that is generally not an issue.

The last part of this is that you need to point the MEM_TYPE pointer to the shared memory that other processes can play with. I have no idea where that is, so I left it pointing to NULL.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.