two weired error in a c programin keil

Status
Not open for further replies.

dizgah

Member level 5
Joined
Nov 8, 2009
Messages
91
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
iran-8par
Visit site
Activity points
2,049
hi every body
i declared a void function
Code:
void SPI_MFRC522_Init(void)
{
..............
}
& used it in a main program

Code:
void RC522_IO_Init(void)
{


	GPIO_InitTypeDef GPIO_InitStruct;
	RCC_APB2PeriphClockCmd(RC522_RESET_GPIO_CLK,ENABLE);
	GPIO_InitStruct.GPIO_Pin = RC522_RESET_PIN;
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_Init(RC522_RESET_GPIO_PORT, &GPIO_InitStruct);
[B][COLOR="#FF0000"]	SPI_MFRC522_Init(void);[/COLOR][/B]
}
and keil shows me this 2 error:
#29:expected an expression
#140:too many arguments in function call
 





There is actually nothing weird about the error message.

When a function/routine's parameter list is defined as "void," you must call the function/routine with an empty parameter list, instead of the keyword "void."

Instead of:

Code:
void RC522_IO_Init(void)
{


	GPIO_InitTypeDef GPIO_InitStruct;
	RCC_APB2PeriphClockCmd(RC522_RESET_GPIO_CLK,ENABLE);
	GPIO_InitStruct.GPIO_Pin = RC522_RESET_PIN;
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_Init(RC522_RESET_GPIO_PORT, &GPIO_InitStruct);
	[COLOR="#FF0000"]SPI_MFRC522_Init(void);[/COLOR]
}

Try:

Code:
void RC522_IO_Init(void)
{


	GPIO_InitTypeDef GPIO_InitStruct;
	RCC_APB2PeriphClockCmd(RC522_RESET_GPIO_CLK,ENABLE);
	GPIO_InitStruct.GPIO_Pin = RC522_RESET_PIN;
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_Init(RC522_RESET_GPIO_PORT, &GPIO_InitStruct);
	[COLOR="#FF0000"]SPI_MFRC522_Init();[/COLOR]
}


BigDog
 
Reactions: dizgah

    dizgah

    Points: 2
    Helpful Answer Positive Rating
really thanks
then when we set void for input argument of function?
whats difference ?
WBR
 

then when we set void for input argument of function?
whats difference ?

I'm not sure I understand your question. Can you provide an example code snippet as to what you are referring?

void routine(void)
{
..............
}

In defining the above routine, the first void in green indicates the routine does not return a value of any type.

The second void in blue, indicates the routine neither expects nor accepts a parameter of any type to be passed.

One of the only other uses of the keyword void is to define a pointer of type void, essentially a generic pointer type.

If you would provide some examples specific to your question, I should be able to elaborate on the specifics of the situation.


BigDog
 
Reactions: dizgah

    dizgah

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…