Reputation: 161
I'm trying to set up VS Code for c++ on windows. I generated a c_cpp_properties.json file and added the necessary directories; however, the red squiggly line remains underneath all the lines where I am including a header. Is this some sort of bug? I know that my paths are correct.
The following headers are used:
#include "stdlib.h"
#include "stdio.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <time.h>
I'm using minGW; therefore, the relevant part of the c_cpp_properties.json file looks like this:
"name": "Win32",
"includePath": [
"C:/MinGW/include",
"C:/MinGW/lib/gcc/mingw32/5.3.0/include/c++"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"browse": {
"path": [],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
Appreciate any help.
Upvotes: 1
Views: 1430
Reputation: 1056
stdlib.h
and stdio.h
are C headers.
In C, you would include a header like this:
#include <headername.h>
In C++, you include C headers by dropping the .h
and adding a c
to the beginning, like this:
#include <cheadername>
Also, I doubt you have stdio.h and stdlib.h in the same folder as your project. So you would use angled brackets (braces? brackets?) instead of quotes.
So your first two includes become this.
#include <cstdio>
#include <cstdlib>
I'm unfamiliar with the ins and outs of MinGW/Visual Stdio/Windows, but I hope this helps.
Upvotes: 2