EDN Admin
Well-known member
Hi everyone,
This is my first post, so please be nice.
I am an inexperienced C programmer and have not used Visual Studio for long. I have found that there are many things that confuse me in the way that VS works, of which most are related to do with the including of files in the project solution. Previously,
when using other methods of compiling C code I have used compilers such as GCC and the like. In these anything that must be included, i.e. header files (.h) and source files (.c) must be included in the main.c, using the #include directive. However, on starting
to use VS I soon realized that this wasnt the case. It seems that although .h files are required to be included in the main.c, that the .c analogues are not. This I understand is being covered by the adding of the files into the solution explorer
tree, on the left hand side of the VS work area. However, this rule doesnt seem to stick in all cases. Some .h files can be omitted from the main.c and still get included? This confuses me. In addition, I have learnt that although this is not usually the
case, sometimes you dont even need to add the directory holding these additional files into the solution properties. To confuse me further, the red squiggly line that appears under files that cannot be found, doesnt always make any difference. In many cases
the solution still compiles.
I suppose what Im asking is;
how does VS search for these additional files?
Which ones are required to be declared in the main.c?
How does using #include"pathfile.h" change things?
In most cases I can get my code to compile, but I just dont always know why
I hope this makes sense.
Thanks in advance,
Loz
View the full article
This is my first post, so please be nice.
I am an inexperienced C programmer and have not used Visual Studio for long. I have found that there are many things that confuse me in the way that VS works, of which most are related to do with the including of files in the project solution. Previously,
when using other methods of compiling C code I have used compilers such as GCC and the like. In these anything that must be included, i.e. header files (.h) and source files (.c) must be included in the main.c, using the #include directive. However, on starting
to use VS I soon realized that this wasnt the case. It seems that although .h files are required to be included in the main.c, that the .c analogues are not. This I understand is being covered by the adding of the files into the solution explorer
tree, on the left hand side of the VS work area. However, this rule doesnt seem to stick in all cases. Some .h files can be omitted from the main.c and still get included? This confuses me. In addition, I have learnt that although this is not usually the
case, sometimes you dont even need to add the directory holding these additional files into the solution properties. To confuse me further, the red squiggly line that appears under files that cannot be found, doesnt always make any difference. In many cases
the solution still compiles.
I suppose what Im asking is;
how does VS search for these additional files?
Which ones are required to be declared in the main.c?
How does using #include"pathfile.h" change things?
In most cases I can get my code to compile, but I just dont always know why
I hope this makes sense.
Thanks in advance,
Loz
View the full article