C #include errors in VS Code, cannot open libraries - c

I use Ubuntu 18.04, VS Code and C/C++ extension and I was trying to test the code from this other question but got the following error:
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/home/alan/Desktop/C/test/main.c).
Also, it says that it can't open source files from "conio.h" to "iostream.h"...
I tried using vcpkg as VSC suggests but it didn't work :/
The first 3 libraries are okay as always, can anyone help me with the others? Thanks!
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <conio.h> //Can't
#include <graphics.h> //open
#include <dos.h> //those
#include <iostream.h> //four

Related

Eclipse "error: no such file or directory" while the header does exist

I'm working on automatic unit testing of ESP32 code in eclipse 2022-06 using google test.
For this I have made a new project and connected it with the ESP32 code using a header file.
I have also connected the unit test project with the ESP32 code via
properties > C/C++ General > Paths and Symbols.
As seen in the picture below.
When running the ESP32 code I get no errors but when I try to run the unit test I get "fatal error: freertos/FreeRTOS.: No such file or directory". However this path can be found in the EPS32 project that im testing.
Does anyone know how to solve this?
#include "main/main.h"
Part of the unit test code
#ifndef MAIN_DOT_H
#define MAIN_DOT_H
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "rom/gpio.h"
#include "esp_intr_alloc.h"
#include "esp_attr.h"
#include "driver/timer.h"
#include "esp_task_wdt.h"
#include "soc/timer_group_struct.h"
#include "soc/timer_group_reg.h"
#include "driver/mcpwm.h"
Part of the header file
#include "main.h"
Part of the ESP32 code
To repeat the question, how can I solve this error?

Visual Studio 2019 custom shortcut

In a visual studio project it often happens to create several files and write a bunch of lines to include the necessary libraries / headers. I was wondering if it was possible to automate the process with a custom shortcut; for example, in my case, I would like to insert the following lines:
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
for example pressing CTRL+MAIUSC+M. Is that possible?

Eclipse + C: unresolved inclusion <ulfius.h>

I am trying to write a code in C in Eclipse, but I am getting an error while trying to include library ulfius.
#include <stdio.h>
#include <string.h>
#include <time.h>
error "Unresolved inclusion" here-> #include <ulfius.h>
And when I try to run it I'm getting "Launch failed. Binary not found". Any idea how could I fix this?

TURBO C++: Unable to open include file stdio.h

I am trying to compile a simple C program using TUrbo C++ 3.2. But getting the following error: Unable to open include file 'STDIO.h'
I do have these files in INCLUDE library.
Cant help you if you dont post your code. Check if you use #include <cstdio> (not #include "cstdio" or #include <cstdio.h> or #include "cstdio.h".
#include <cstdio> will always work.

Compile C program with visual studio

I am required to explain what the program located in the following links does:
main.c
csapp.c
csapp.h
I compile the following code in linux as:
............................................................
(note all three files have to be in the same working directory for compilation to work. )
that command is: gcc main.c csapp.c
when I execute that command I get the executable: a.out and I get no compilation errors!
That executable file can be downloaded from here (I don't think you need that file plus I will not execute that file if I where you).
Anyways I think that if I could debug the program I will be able to understand better what is going on. As a result I have created a C++ console empty console project in visual studio. I will like to include the same files in there and be able to compile it. I have never used c++ before and I don't really understand where to place header files. This is what I have done hoping to be able to compile the program:
The program will not compile if I place the files like that.
I have also tried placing all the files in the same directory just like on the linux virtual machine:
that does not compile either.
How will I be able to compile that program with visual studio?
If you look at csapp.h you'll notice it tries to include these headers:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <setjmp.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <errno.h>
#include <math.h>
#include <pthread.h>
#include <semaphore.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
Some of these are std C headers, but others are specific to POSIX/Linux/UNIX style operating systems (pthread.h for example). You won't be able to use these libraries on Windows or in Visual Studio unless you're doing something unusual like compiling against Cygwin libraries.
If you want to get an understanding of what the program is doing, there's a number of things you could do. First off, just read through the code and look up the functions it calls in the man pages which document those functions (If you have gcc, I guess you also have man?) second, yes you could print to console to figure stuff out. You could also use a debugger like gdb to step through the program, it's not as intuitive as VS debugger but it works...

Resources