2

I'm writing code for a USB bootloader. When I compiled the code, I got 2 of the following error:

Invalid Initializer

The error referred to the following lines of code:

static volatile usb_internal_sram_t sr;         
static volatile usb_internal_sram_t usb_sram = &sr;

usb_control_t ctr;                  
static usb_control_t usb_ctrl = &ctr;

Before someone suggests malloc(), this is an embedded system. Dynamic memory allocation is not advised as it can slow down the system. Hence, that is why I attempted to initialize the struct pointers this way. I thought this method would be ok, but apparently not. Anyone have any ideas? Thank you in advance!

1
  • "Initializing a pointer"? Where is the pointer??? I don't see any pointers being declared in your code. Why are you trying to initialize a struct object with a pointer value? Commented Aug 2, 2012 at 21:27

2 Answers 2

2

You are missing the * token to declare your usb_sram and usb_ctrl objects as pointers.

Sign up to request clarification or add additional context in comments.

2 Comments

Oh wow, I'm an idiot. I totally didn't notice I forgot the *.
Are you going to accept the answer? That would be the right thing to do.
1
static volatile usb_internal_sram_t sr;
static volatile usb_internal_sram_t usb_sram = &sr;

you probably meant

static volatile usb_internal_sram_t sr;
static volatile usb_internal_sram_t* usb_sram = &sr;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.