reason for "error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token"

HEckardt
Posts: 11
Joined: Wed Aug 16, 2023 3:13 pm

reason for "error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token"

Postby HEckardt » Sun Jan 21, 2024 4:30 pm

Dear Forum Members,

I defined/declared a struct "udp_buf_t" as "rx_tx_buf":

Code: Select all


typedef enum
{
	LAN_BEGIN,
	START_WPS,
	LAN_FOUND,
	LAN_NOT_FOUND,
	BROADCAST_SEND,
	HE_MON_FOUND,
	HE_MON_NOT_FOUND,
	MSG_TO_SEND,
	WAIT_FOR_ANS,
	GOT_HE_MON_ANS,
	MAIN_IDLE
}ctrl_lan_state_t;


typedef struct
{
	char rx_buffer[64];
	char tx_buffer[64];
	ctrl_lan_state_t lan_state_ctrl;
	struct sockaddr_in sauna_mon_adr;
}udp_buf_t;

	udp_buf_t rx_tx_buf;
	
	rx_tx_buf.sauna_mon_adr.sin_family = AF_INET;  	// row 104
	rx_tx_buf.sauna_mon_adr.sin_port = htons(3333);	// row 105
	rx_tx_buf.lan_state_ctrl = MAIN_IDLE;			// row 106



but when I want to build it, I get this error messages from "idf.py":
C:/ESP32_Projects/Sauna_Ctrl/main/he_lan_part.h: At top level:
C:/ESP32_Projects/Sauna_Ctrl/main/he_lan_part.h:104:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
104 | rx_tx_buf.sauna_mon_adr.sin_family = AF_INET;
| ^
C:/ESP32_Projects/Sauna_Ctrl/main/he_lan_part.h:105:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
105 | rx_tx_buf.sauna_mon_adr.sin_port = htons(3333);
| ^
C:/ESP32_Projects/Sauna_Ctrl/main/he_lan_part.h:106:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
106 | rx_tx_buf.lan_state_ctrl = MAIN_IDLE;
| ^
In file included from C:/Espressif/frameworks/esp-idf-v5.1/components/lwip/lwip/src/include/lwip/sockets.h:49,

I`m quite sure, I use the correct sytax in the rows 104, 105, 106. So, what could be made wrong?


Thank you for your support.

Greetings
Henry

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: reason for "error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token"

Postby ESP_Sprite » Mon Jan 22, 2024 1:34 am

Are you putting those assignments outside of a function? You can't really do stuff like that globally.

HEckardt
Posts: 11
Joined: Wed Aug 16, 2023 3:13 pm

Re: reason for "error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token"

Postby HEckardt » Mon Jan 22, 2024 10:27 am

Hi ESP_Sprite,

yes, you are right, I did it globally. Thank you for the hint. I`ll assign the values inside a function.

Greetings
Henry

Who is online

Users browsing this forum: No registered users and 8 guests