Where are the c header files on my system?

Jerry Feldman gaf at blu.org
Tue May 19 10:34:28 EDT 2009


On 05/19/2009 08:48 AM, Kevin D. Clark wrote:
> Lori Nagel writes:
>
>   
>> I've been using gcc in Linux and cc in Unix.  I have not been using
>> an IDE, only the terminal shell and a text editing program for the C
>> files. On both computers c programs compile and run, however, the
>> compilers are different and have different options, and some code
>> that compiles and runs on one doesn't on the other.  (what I mean is
>> why is gcc so lax while cc is so mean.)
>>     
>
> I strongly recommend that when you compile all of your C code with gcc
> that you add the arguments "-Werror -Wall -Wcast-qual".
>
> You can either do this or spend your time chasing crazy problems.
> Your choice.
>
>   
>> What I want to know is if there any easy way I could find out where
>> my .h files are on my computers such as stdio.h? Also, would I be
>> able to find the function prototypes for things like scanf in them
>> or would I have to go somewhere else?
>>     
>
> If you want to know where to #include things from, the very first
> place you should look is in the manual page.  If you type "man scanf"
> you will see this:
>
>    SYNOPSIS
>        #include <stdio.h>
>        int scanf(const char *format, ...);
>        int fscanf(FILE *stream, const char *format, ...);
>        int sscanf(const char *str, const char *format, ...);
>
>
> The way that you should interpret this is "if I want to use the
> scanf() function, I need to #include <stdio.h> in my code.
>
>
>   
>> Another thing, why oh why did they decide to seperate out libm.a
>> from the rest of the C programming libriaries so that you have to
>> include it? It used to make me so upset until I read intro to gcc.
>>     
>
> Again, the problem that you are describing here is easily remedied if
> you consult the manual page.  For example, "man atanf" produces:
>
>    SYNOPSIS
>        #include <math.h>
>
>        double atan(double x);
>        float atanf(float x);
>        long double atanl( long double x);
>
>        Link with -lm.
>
>
> You should interpret this to mean (1) if you want to use the math
> library, you need to #include <math.h> and (2) if you want to use the
> math library, you need to link against it by adding the argument "-lm"
> to your invocation of the linker, like so: "cc foo.o -o foo -lm".
>
>
>   
>> Please someone answer my question because I have been wanting to
>> know the answer for about 3 years now, and I think that is a long
>> enough time to wait.  I have done enough reading of manuals to know
>> that most of them don't answer the questions that people have. I'm
>> planning to write the ultimate newbie C programming book for
>> Gnu/Linux because it doesn't currently exist.
>>     
>
> The two best books that I know of on the C language are Kernighan and
> Ritchie's book and Harbison and Steele's book.
>
>   
I agree here. about the books. With K&R make sure you get the most 
recent book since it incorporates the standards. And speaking of 
standards, there are essentially 3 major C language standards,
1. K&R - not really a standard, but this was primarily the standard 
before the 1989 standard
2. ISO/IEC 9899:1990 (sometimes referred to as C89 since this reflects 
the 1989 ANSI standard. This is the first place where function 
prototypes were defined.
3.  ISO/IEC 9899:1999 - This is the latest standard.

You may encounter code in some of the books that is actually wrong, so I 
would also invest in a copy of both of the standards.

-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix
PGP key id: 537C5846
PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB  CA3B 4607 4319 537C 5846


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
Url : http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20090519/23b03830/attachment-0001.bin 


More information about the gnhlug-discuss mailing list