[Courses] C Programming For Absolute Beginners, Lesson 1: Setting Up, First Program

jim jim at well.com
Mon Feb 6 05:58:13 UTC 2012



    Aha (with thanks). There's the difference between 
#include < xyz.h > 
and 
#include " ../../jersey/work/include/myxyz.h " 

    The  < >  uses the  include  path whereas 
the  "  "  specifies some relative or absolute path 
to some file. 
    Also, the file to be included can be any text 
file, yes? Although no sense in #include-ing a file 
that doesn't follow the rules of the C language, as 
such would cause compile errors and failure. 





On Sun, 2012-02-05 at 20:26 -0600, Kathryn Hogg wrote:
> On 2012-02-05 18:45, Jacinta Richardson wrote:
> > On 06/02/12 10:49, jim wrote:
> >>      Note that the #include preprocessor directive seems to take
> >> <stdio.h>
> >> as an argument.
> >>      The<  >  angle bracket characters have a special meaning:
> >> /usr/include/
> >>
> >
> > The angle brackets refer to the system directories, which might not
> > always be /usr/include but could even be /opt/usr/include etc.
> 
> That's not quite correct.  When you have a #include file surrounded by 
> angle brackets, it indicates to look for the file according to the 
> include path.  The compiler typically has a built in include path but 
> you can extended via command line arguments or environment variables:
> 
> gcc -I/usr/local/include  will add /usr/local/include to the front of 
> the include path.
> 
> When you do a #include with double quotes (#include "file.h") that 
> means to search the same directory as the file which is doing the 
> #include.
> 
> For example, if /home/kathryn/src/foo.c  does
> 
> #include "foo.h"
> 
> then the compiler will search in /home/kathryn/src for foo.h and if it 
> doesn't find it, it will search the include path as normal.
> 
> 
> 




More information about the Courses mailing list