I'm learning C now using vscode. I got curious and tried modifying the headerfiles. stdio.h to be specific and I found some really peculiar behavior. I studied the behavior using the simple Helloworld program.
infos: Windows 10 OS, VScode v1.56.0, Compiled using CL not gcc, ucrt file path:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
The code:
#include<stdio.h>
int main()
{
printf("Hello world!");
}
So first I tried adding some random lines in the header file and save it. The code ran fine without any errors. I tried it after restarting. It still worked fine.
Then I commented the whole file with 2k+ and saved it and was expecting for the compiler to tell me that printf is not declared anywhere. But still again the code worked fine.
Then I reverted all changes, copied the header file to another folder and deleted the file in the ucrt folder So. Now for the first time compiler said printf isn't declared anywhere.
I modified the headerfile outside and copied it to the urct folder and the code worked fine again. So, as I checked into the file (in ucrt) the changes I made isn't showing here.
So I again deleted the headerfile in ucrt folder, cleared everyline added 2 3 random lines there saved it. And then pasted it in the ucrt to see that code still works really fine. And as I checked the header file.......It is the same old stdio.h that was when I installed it.
And Finally....when I copied the header file in ucrt and pasted it outside. And to my surprise It had the lines I added in No.5
There is only one explanation that I can think of...That VScode overrides any changes in the file.
So here are my questions:
- How headerfiles are processed in vscode.
- Can we actually modify it(The one in ucrt folder)
- What is actually happening in the steps I mentioned above. Why these weird outcomes.
- What is the difference between compiling with CL and with GCC.
NOTE: I know it's too lengthy I just wanted to give as much information I have.