Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

two weired error in a c programin keil

Status
Not open for further replies.

dizgah

Member level 5
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
1.jpg
 

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
View attachment 109703




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
 
  • Like
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
 
  • Like
Reactions: dizgah

    dizgah

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

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top