cancel
Showing results for 
Search instead for 
Did you mean: 

avertissing with a passing argument in "C"

JJoao.1
Associate III

Hello everybody,

I am currently programming on a STM32G0 for a screen with the st7567 driver.
I created a function to display a text.
When indicating the information on the font I have a warning from the cubeIDE compiler.

in my main.c

 

st7567_Write_Text_Page(25, 2, Buffer, microsoftSansSerif_8pt, INFO_microsoftSansSerif_8pt);

 

advertissing : passing argument 5 of 'st7567_Write_Text_Page' from incompatible pointer type [-Wincompatible-pointer-types]

 

The prototype's  function is declared in a file named st7567_driver.h like this :

 

void st7567_Write_Text_Page(uint8_t , uint8_t , char* , uint8_t * , uint32_t *);

 

advertissing : expected 'uint32_t *' {aka 'long unsigned int *'} but argument is of type 'uint32_t (*)[3]' {aka 'long unsigned int (*)[3]'}

 

And the font.c like this :

 

const uint32_t INFO_microsoftSansSerif_8pt[][3] =
{
	{2, 12, 0}, 		//
	{1, 12, 4}, 		// !
	{4, 12, 6}, 		// "
	{6, 12, 14}, 		// #
	{5, 12, 26}, 		// $
-
-
-
	{1, 12, 838}, 		// |
	{3, 12, 840}, 		// }
	{6, 12, 846}, 		// ~
};

 

 

I don't understand why have got an advertissing, certainly because i'm a beginner.

 

Thank you if you can help me.

Jérémy

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

The error is happening because you are passing a pointer to a two-dimensional array while the function is expecting a regular pointer.

 

If you want to write all bytes you have in the array, in consecutive order, you can cast the pointer to the correct type.

st7567_Write_Text_Page(25, 2, Buffer, microsoftSansSerif_8pt, (uint32_t*)INFO_microsoftSansSerif_8pt);

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

The error is happening because you are passing a pointer to a two-dimensional array while the function is expecting a regular pointer.

 

If you want to write all bytes you have in the array, in consecutive order, you can cast the pointer to the correct type.

st7567_Write_Text_Page(25, 2, Buffer, microsoftSansSerif_8pt, (uint32_t*)INFO_microsoftSansSerif_8pt);

 

If you feel a post has answered your question, please click "Accept as Solution".
JJoao.1
Associate III

Thank you very much ! it's work perfectly