EmbDev.net

Forum: ARM programming with GCC/GNU tools arning: passing argument from incompatible pointer type


Author: Joe (Guest)
Posted on:

Rate this post
0 useful
not useful
I'm getting this error from WinARM:

Warning: passing argument 4 of 'AT91F_TWI_ReadByte' from incompatible
pointer type

with this code:

char read[5];

int AT91F_TWI_ReadByte(const AT91PS_TWI pTwi ,int mode, /
                         int int_address, char * data, int nb)
{
   some code here;
}

void main(void)
{
   AT91F_TWI_ReadByte(AT91C_BASE_TWI, LED_CONTROLLER0, 0x02, &read, 1);
}


What is incompatible with the pointer?


- Joe

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
1. Mistake in code, no reason to blame WinARM
2. warning != error
3. test with &read[0] or just read and try to understand the difference
to &read
4. use int main(void) to avoid another warning
5. read a C-book (i.e. Brian W. Kernighan and Dennis M. Ritchie, The C
Programming Language) or C-tutorial soon.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
&read has type char** not char* you simply need just read on its own
which has type char[] which is compatible with char*, or &read[0] which
is a char*.

A char[] when passed as a function parameter always degrades to char* in
any case.

The only difference between a char* and char[] is the value of sizeof();

char read[10] ;
char* pRead = read ;

sizeof(read) == 10
sizeof(pRead) == 4 (on a 32bit architecture such as ARM)

Clifford

Author: Joe (Guest)
Posted on:

Rate this post
0 useful
not useful
Clifford Slocombe wrote:
> &read has type char** not char* you simply need just read on its own
> which has type char[] which is compatible with char*, or &read[0] which
> is a char*.

Thanks Clifford.  The code is a sample from Atmel, so evidently they
don't know what they are doing either.  (By the way, the IAR compiler
doesn't issue any warnings in it's default setup.)

And Martin, I was in no way blaming WinArm!  I love WinARM!  I
appologise for calling the warning an error.

- Joe

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.