Weird C errors when building project on VSCode
Posted: Sun Feb 09, 2025 7:17 pm
Greetings
I am using the ESP-IDF on VSCode, with a ESP32-WROOM-32E. I have started a project with ESP-IDS v5.2.1. I have added a few folders inside the main folder, for different drivers I have written. Essentially, my folder structure is:
Where my drivers (.h and .c files) are in the subfolders of the "main" folder. I have added the folders to the INCLUDE_DIRS, and .c files to the SRCS, in the CMakeLists.txt in the "main" folder. I have tried using a function from the queue/queue.h, which is
I included the header file for "queue" in main.c with its relative file path i.e. "queue\queue.h". I have since encountered many weird issues:
1. I used the init function as follows:
To which I get errors,
It seems I cannot pass the "tx_q" variable by reference, as when I create it as a pointer, the problem goes away and I am only left with one error:
I then, set a variable to "20" and ran the function as such
To which I got more errors:
Please help me fix these errors as I don't know what else to do. What makes everything so weird, is that I have used this module in other projects with no compile errors or warnings, while instantiating tx_q as just a normal struct and not a pointer. Let alone the other errors regarding the "conflicting types".
Any help would be appreciated.
I am using the ESP-IDF on VSCode, with a ESP32-WROOM-32E. I have started a project with ESP-IDS v5.2.1. I have added a few folders inside the main folder, for different drivers I have written. Essentially, my folder structure is:
- - .devcontainer
- - .vscode
- - build
- - components
- - main
- - queue
- - routes
- - serial_protocol
- void queue_init(queue_t *queue, uint16_t *buffer, uint8_t size)
1. I used the init function as follows:
- queue_t tx_q;
- uint16_t tx_q_buffer[20];
- queue_init(&tx_q, tx_q_buffer, 20);
- error: expected declaration specifiers or '...' before '&' token
- 85 | queue_init(&tx_q, tx_q_buffer, 20);
- | ^
- C:/Users/Suvashan/Documents/IDS graf/captive_portal/main/main.c:85:19: error: expected declaration specifiers or '...' before 'tx_q_buffer' 85 | queue_init(&tx_q, tx_q_buffer, 20);
- | ^~~~~~~~~~~
- C:/Users/Suvashan/Documents/IDS graf/captive_portal/main/main.c:85:32: error: expected declaration specifiers or '...' before numeric constant
- 85 | queue_init(&tx_q, tx_q_buffer, 20);
- | ^~
- ninja: build stopped: subcommand failed.
- error: expected ')' before numeric constant
- 85 | queue_init(tx_q, tx_q_buffer, 20);
- queue_t *tx_q;
- uint16_t tx_q_buffer[20];
- uint8_t a = 20;
- queue_init(tx_q, tx_q_buffer, a);
- error: type defaults to 'int' in declaration of 'queue_init' [-Werror=implicit-int]
- warning: parameter names (without types) in function declaration
- error: conflicting types for 'queue_init'; have 'int()'
Any help would be appreciated.