How do you add the stdio.h library to a project ?

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

How do you add the stdio.h library to a project ?

Postby DutchOrange » Tue Jan 05, 2021 9:30 am

So Iam busy with the Mwifi project and want to use printf(); for some testing, But how do you add the stdio.h library to the code ?
When I try use printf(); I just get an error in the build.
Is there an alternative ?
Windows 10 ESP-IDF/MDF 4.1

ESP_Minatel
Posts: 364
Joined: Mon Jan 04, 2021 2:06 pm

Re: How do you add the stdio.h library to a project ?

Postby ESP_Minatel » Tue Jan 05, 2021 1:47 pm

Hi,

Can you share the error you got?

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

Re: How do you add the stdio.h library to a project ?

Postby DutchOrange » Tue Jan 05, 2021 2:06 pm

Thanks for the reply.
The error is: I put what I think is necessary but I also have the .txt file with the rest of the error code.

Code: Select all

les/__idf_main.dir/no_router_example.c.obj   -c ../main/no_router_example.c
../main/no_router_example.c: In function 'app_main':
../main/no_router_example.c:280:2: error: expected declaration specifiers before 'printf'
  printf("Hello, This is to test the printf()  \n");       //Adding to test printf();
  ^~~~~~
[915/956] Building C object esp-idf/mdebug/CMakeFiles/__idf_mdebug.dir/mdebug_cmd.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Attachments
Error.txt
(4.47 KiB) Downloaded 539 times

ESP_Minatel
Posts: 364
Joined: Mon Jan 04, 2021 2:06 pm

Re: How do you add the stdio.h library to a project ?

Postby ESP_Minatel » Tue Jan 05, 2021 2:43 pm

Hi,

Could you share your code, or part of it? I think you may have an error before your printf function call.

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

Re: How do you add the stdio.h library to a project ?

Postby DutchOrange » Tue Jan 05, 2021 7:17 pm

Hey, So here is the code. It is the Mwifi example, I will upload as TXT and .c
Attachments
no_router_example.c
(10.99 KiB) Downloaded 570 times
Code.txt
(10.99 KiB) Downloaded 550 times

ESP_Minatel
Posts: 364
Joined: Mon Jan 04, 2021 2:06 pm

Re: How do you add the stdio.h library to a project ?

Postby ESP_Minatel » Tue Jan 05, 2021 8:15 pm

Hi,

You need to change from:

Code: Select all

void app_main()
 printf("Hello, This is to test the printf()  \n");       //Adding to test printf(); 
{
to

Code: Select all

void app_main()
{
 printf("Hello, This is to test the printf()  \n");       //Adding to test printf();
Probably this is the issue.

DutchOrange
Posts: 74
Joined: Fri Dec 04, 2020 4:23 pm

Re: How do you add the stdio.h library to a project ?

Postby DutchOrange » Wed Jan 06, 2021 6:48 am

Thanks SO much, I cant believe I missed such a small thing with the brackets.

Who is online

Users browsing this forum: No registered users and 7 guests