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.

[SOLVED] static declaration follows non-static declaration

Status
Not open for further replies.

153rd

Member level 1
Joined
Mar 4, 2011
Messages
34
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Activity points
1,545
Hey guys,

I'm working on some C code for an STM32F4Discovery board.

Code:
#include "main.h"

int main(void)
{
	//Enable HSE clock
	RCC_HSEConfig(RCC_HSE_ON);
	//Wait for clock to stabilize
	while (!RCC_WaitForHSEStartUp());

    init();
    while(1)
    {
		//GPIO_SetBits(GPIOD, LED[counter % 4]);
		while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET); // Wait for Empty
		USART_SendData(UART4, 'h');

		GPIO_SetBits(GPIOD, LED[2]);
		//VC0706_sendCommand(0xAA, 0x18, 0x81);
		//while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
		//USART_SendData(USART2, 'Y');

		GPIOE->BSRRH |= GPIO_Pin_2; // set PE2 (CS) low
		SPI_I2S_SendData(SPI1, 0xAA);  // transmit data
		//received_val = SPI1_send(0x00); // transmit dummy byte and receive data
		GPIOE->BSRRL |= GPIO_Pin_2; // set PE2 (CS) high
		GPIO_ResetBits(GPIOD, LEDS);
    }
}

void init()// <<error starts here
{
When compiling, I get the following error:

static declaration of 'insert_function_here' follows non-static declaration (init() in my case)

I've found some topics on stackexange here, but those solutions don't completely apply to my problem.
The suggestions I've seen until now is that it has something to do with the curly brackets, however I don't see how that applies to the code above.

my main.h file is as follows:

Code:
#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_usart.h"
#include "stm32f4xx_tim.h"
#include "VC0706.h"

const uint16_t LEDS = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
const uint16_t LED[4] = {GPIO_Pin_12, GPIO_Pin_13, GPIO_Pin_14, GPIO_Pin_15};

void init(void);

void USART3_IRQHandler();
void UART4_IRQHandler();

Furthermore, my compiler ends with:

error: expected declaration or statement at end of input

Which also seems to suggest something is off with braces or parentheses..
When I empty my main completely, like this:

Code:
#include "main.h"

int main(void)
{

}

void init()
{

}

I keep having the same error, starting at the init function.
Removing void doesn't work(which makes sense, compiler things I'm declaring 'init' for a 2nd time right?)
Does anyone have a suggestion/tip/solution to this error I could take a look at?

It would be much appreciated :)

Thanks!
 

looks like unbalanced {} - however, nothing obvious in main.h or main.c so probably in one of the other header files
check the other .h files
in particular what is in VC0706.h
try commenting each #include out - you will get errors but it may indicate the file which is causing the "error: expected declaration or statement at end of input"
 
Last edited:
  • Like
Reactions: 153rd

    153rd

    Points: 2
    Helpful Answer Positive Rating
Horace! Thanks a lot.

Had a floating bracket in vc0706.h, seems like the compiler was right, as always.

Regards
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top