Weird C errors when building project on VSCode

Planetary Systems
Posts: 2
Joined: Sat Nov 18, 2023 5:53 pm

Weird C errors when building project on VSCode

Postby Planetary Systems » 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:
  1. - .devcontainer
  2. - .vscode
  3. - build
  4. - components
  5. - main
  6.    - queue
  7.    - routes
  8.    - serial_protocol
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
  1. void queue_init(queue_t *queue, uint16_t *buffer, uint8_t size)
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:
  1. queue_t tx_q;
  2. uint16_t tx_q_buffer[20];
  3.  
  4. queue_init(&tx_q, tx_q_buffer, 20);
To which I get errors,
  1. error: expected declaration specifiers or '...' before '&' token    
  2.    85 | queue_init(&tx_q, tx_q_buffer, 20);
  3.       |            ^
  4. 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);
  5.       |                   ^~~~~~~~~~~
  6. C:/Users/Suvashan/Documents/IDS graf/captive_portal/main/main.c:85:32: error: expected declaration specifiers or '...' before numeric constant
  7.    85 | queue_init(&tx_q, tx_q_buffer, 20);
  8.       |                                ^~
  9. ninja: build stopped: subcommand failed.
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:
  1.  error: expected ')' before numeric constant
  2.    85 | queue_init(tx_q, tx_q_buffer, 20);
I then, set a variable to "20" and ran the function as such
  1. queue_t *tx_q;
  2. uint16_t tx_q_buffer[20];
  3.  
  4. uint8_t a = 20;
  5.  
  6. queue_init(tx_q, tx_q_buffer, a);
To which I got more errors:
  1. error: type defaults to 'int' in declaration of 'queue_init' [-Werror=implicit-int]
  2. warning: parameter names (without types) in function declaration
  3.  error: conflicting types for 'queue_init'; have 'int()'
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.

Who is online

Users browsing this forum: No registered users and 109 guests