List of Standard Header Files in C and C++

List of standard header files in C and C++

Try here : http://en.cppreference.com/w/

However, you may also be refering to the header files of your OS. These can be found either on MSDN (Windows) or by man command (POSIX systems). Or another source if you're on another OS.

Where should standard library include be writen ? .c or .h file?

Header files within your application should only include system headers which are required to declare further interfaces within the header.

For example -- if your header includes functions which take a FILE * as a parameter, it should #include <stdio.h>. If it declares a structure containing a uint32_t, it should #include <stdint.h>. And so on.

System headers which are only used within the implementation should be left to the .c file. Your header should not #include <stdio.h> simply because the implementation calls printf(), for example.

C system header file descriptions

For language-defined headers, the library section (section 7) of the C standard (PDF) is definitive. There's a subsection for each header, though <limits.h> and <float.h> are described in 5.2.4.2.

POSIX is here; access is free, but you have to sign up for an account. (I'm actually not 100% sure of the relationship among POSIX, SUS, and IEEE Std 1003.1.)

EDIT :

Mac OSX man pages are available here.

But consider that you might be approaching this from the wrong direction. When writing code, a better approach is typically to (a) decide what you want to do, (b) find a function that will do it, and (c) read the function's documentation to determine which header you need to #include. A given header doesn't necessarily have a coherent meaning.

C - Header files

These files are provided by the C standard library to make accomplishing common tasks easier. As to why the declarations and definitions are kept in separate files, it's for convenience and maintainability reasons. The same reason why, for example, the Linux kernel is not defined in a single C file, even though theoretically it could be.

Creating Library Header Files in C++? (As opposed to old-fashined C?)

There is no difference. Most, if not all, of the standard C++ library include files do not have a .h extension, to distinguish them from C library includes. The original C standard header file names are deprecated in C++, although virtually every compiler still supports them, and changed in name to c followed by the original C file name, without the .h extension.

For example: In C, the header file relating to strings is string.h, but the C++ header file relating to strings is string. The original C header file can also be accessed in C++ as cstring.

How can I find the header files of the C programming language in Linux?

gcc -H ... will print the full path of every include file as a side-effect of regular compilation. Use -fsyntax-only in addition to get it not to create any output (it will still tell you if your program has errors). Example (Linux, gcc-4.7):

$ cat > test.c
#include <stdbool.h>
#include <stdio.h>
^D
$ gcc -H -fsyntax-only test.c
. /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stdbool.h
. /usr/include/stdio.h
.. /usr/include/features.h
... /usr/include/x86_64-linux-gnu/bits/predefs.h
... /usr/include/x86_64-linux-gnu/sys/cdefs.h
.... /usr/include/x86_64-linux-gnu/bits/wordsize.h
... /usr/include/x86_64-linux-gnu/gnu/stubs.h
.... /usr/include/x86_64-linux-gnu/bits/wordsize.h
.... /usr/include/x86_64-linux-gnu/gnu/stubs-64.h
.. /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h
.. /usr/include/x86_64-linux-gnu/bits/types.h
... /usr/include/x86_64-linux-gnu/bits/wordsize.h
... /usr/include/x86_64-linux-gnu/bits/typesizes.h
.. /usr/include/libio.h
... /usr/include/_G_config.h
.... /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h
.... /usr/include/wchar.h
... /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stdarg.h
.. /usr/include/x86_64-linux-gnu/bits/stdio_lim.h
.. /usr/include/x86_64-linux-gnu/bits/sys_errlist.h

The dots at the beginning of each line count how deeply nested the #include is.



Related Topics



Leave a reply



Submit