0

I have a simple function on c++ which takes 2 arguments:

read(uint32_t *buffer, uint32_t num_words){
    ...
}

When I try to call it I get an error because the arguments I pass are probably wrong unsigned long*, unsigned long:

uint32_t addr = 5;
uint32_t buf[5];
read(buf,addr);

I'm not sure why this is wrong. Any ideas?

matt
  • 2,312
  • 5
  • 34
  • 57
  • 1
    Depends on what sort of platform you are running the program on, say in certain systems `int` is 32 bit, so you don't need `unsigned long`, try using `unsigned int`. – Bharadwaj Jun 11 '15 at 08:29
  • It's on an embedded system using freeRTOS, `int` doesn't work either, I'm puzzled – matt Jun 11 '15 at 08:32
  • 1
    *What* errors do you get? Please edit your question to include the complete and unedited error log. Also, some operating systems might already have a `read` system call, you sure it's not the case here? – Some programmer dude Jun 11 '15 at 08:34
  • 1
    FreeRTOS can be installed on both 16 and 32 bit processors. Why do you think the error is "probably" because of the inconsistent data type? what exactly is the error. – Bharadwaj Jun 11 '15 at 08:35
  • The error is: `undefined reference to Storage::readFlash(unsigned long*, unsigned long)`. I have now realised that the function was missing the namespace `Storage::` – matt Jun 11 '15 at 08:39
  • 1
    Guess the problem is solved – Bharadwaj Jun 11 '15 at 08:41

1 Answers1

0

The problem might be because the compiler is not able to convert pointer to const pointer(that is array variable). Change the prototype of of read to read(uint32_t buffer [], uint32_t num_words).. This will work.

user891558
  • 23
  • 1
  • 3