Where could I find the list of all header files in C and C++?
While I am building a library, I am getting an error like 'tree.h not found'.
I suppose this is a standard header file in C and C++. This raised in me the curiosity to know all the header files and their contribution.
Is there a place I can search for?
I am working on Solaris Unix.
The header 'tree.h' is not standard anywhere.
C Standards
ISO/IEC 9899:1990 (C89, C90)
The 15 standard headers in C89 are:
<assert.h> <limits.h> <signal.h> <stdlib.h>
<ctype.h> <locale.h> <stdarg.h> <string.h>
<errno.h> <math.h> <stddef.h> <time.h>
<float.h> <setjmp.h> <stdio.h>
ISO/IEC 9899:1990/Amd.1:1995
The 3 extra headers introduced in C94* (Amendment 1) are:
<iso646.h> <wchar.h> <wctype.h>
ISO/IEC 9899:1999 (C99)
The 6 extra headers in C99 are:
<complex.h> <inttypes.h> <stdint.h> <tgmath.h>
<fenv.h> <stdbool.h>
ISO/IEC 9899:2011 (C11)
The 5 extra headers in C2011 (for a total of 29) are:
<stdalign.h> <stdatomic.h> <stdnoreturn.h> <threads.h> <uchar.h>
ISO/IEC 9045:2008 (POSIX 2008, Single Unix Specification)
Note that POSIX requires many more headers (82, including all the C99 headers). The list below repeats the standard C (C99) headers. Windows requires a different set of headers, of course.
<aio.h> <libgen.h> <spawn.h> <sys/time.h>
<arpa/inet.h> <limits.h> <stdarg.h> <sys/times.h>
<assert.h> <locale.h> <stdbool.h> <sys/types.h>
<complex.h> <math.h> <stddef.h> <sys/uio.h>
<cpio.h> <monetary.h> <stdint.h> <sys/un.h>
<ctype.h> <mqueue.h> <stdio.h> <sys/utsname.h>
<dirent.h> <ndbm.h> <stdlib.h> <sys/wait.h>
<dlfcn.h> <net/if.h> <string.h> <syslog.h>
<errno.h> <netdb.h> <strings.h> <tar.h>
<fcntl.h> <netinet/in.h> <stropts.h> <termios.h>
<fenv.h> <netinet/tcp.h> <sys/ipc.h> <tgmath.h>
<float.h> <nl_types.h> <sys/mman.h> <time.h>
<fmtmsg.h> <poll.h> <sys/msg.h> <trace.h>
<fnmatch.h> <pthread.h> <sys/resource.h> <ulimit.h>
<ftw.h> <pwd.h> <sys/select.h> <unistd.h>
<glob.h> <regex.h> <sys/sem.h> <utime.h>
<grp.h> <sched.h> <sys/shm.h> <utmpx.h>
<iconv.h> <search.h> <sys/socket.h> <wchar.h>
<inttypes.h> <semaphore.h> <sys/stat.h> <wctype.h>
<iso646.h> <setjmp.h> <sys/statvfs.h> <wordexp.h>
<langinfo.h> <signal.h>
Note, too, that X/Open Curses requires another set of headers. There was a new version (Release 7) of that specification released in November 2009 (the first update since 1996 — the primary differences are the loss of official support for termcap and pre-standard C <varargs.h> header).
<curses.h> <term.h> <uncntrl.h>
Linux Standards Base
There are other headers that you might need to use. For example, there is no mention of <getopt.h> in these lists, but if you are using GNU Getopt (for long options, for example), you will need and use that header. It is standard on Linux according to the LSB, Linux Standards Base. An older version of the LSB was defined as ISO/IEC 23360:2006 in multiple parts; as of 2014-09-21, the current version of the LSB is 4.1 but version 5.0 is in beta. There is a section of the document that defines which headers are included, but there is no convenient table of the headers in the version I looked at. It is closely aligned with POSIX, but has extra facilities beyond what POSIX defines.
C++ Standards
ISO/IEC 14882:1998 (C++98)
The standard lists 32 headers specific to C++:
<algorithm> <iomanip> <list> <ostream> <streambuf>
<bitset> <ios> <locale> <queue> <string>
<complex> <iosfwd> <map> <set> <typeinfo>
<deque> <iostream> <memory> <sstream> <utility>
<exception> <istream> <new> <stack> <valarray>
<fstream> <iterator> <numeric> <stdexcept> <vector>
<functional> <limits>
There are also 18 headers corresponding to headers from C (corresponding to C94):
<cassert> <ciso646> <csetjmp> <cstdio> <ctime>
<cctype> <climits> <csignal> <cstdlib> <cwchar>
<cerrno> <clocale> <cstdarg> <cstring> <cwctype>
<cfloat> <cmath> <cstddef>
Intriguingly, Annex D (§D.7) lists a deprecated header, <strstream>, that is not mentioned earlier in the standard. Including that header with GCC (g++) 7.2.0 generates a warning:
/opt/gcc/v7.2.0/include/c++/7.2.0/backward/backward_warning.h:32:2:
warning: #warning This file includes at least one deprecated or antiquated
header which may be removed without further notice at a future date.
Please use a non-deprecated interface with equivalent functionality
instead. For a listing of replacement headers and interfaces, consult
the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
The header <strstream> is explicitly listed in the other versions of the standard.
ISO/IEC 14882:2011 (C++11)
The 53 C++ headers in C++11 are:
<algorithm> <initializer_list> <numeric> <system_error>
<array> <iomanip> <ostream> <thread>
<atomic> <ios> <queue> <tuple>
<bitset> <iosfwd> <random> <type_traits>
<chrono> <iostream> <ratio> <typeindex>
<codecvt> <istream> <regex> <typeinfo>
<complex> <iterator> <scoped_allocator> <unordered_map>
<condition_variable> <limits> <set> <unordered_set>
<deque> <list> <sstream> <utility>
<exception> <locale> <stack> <valarray>
<forward_list> <map> <stdexcept> <vector>
<fstream> <memory> <streambuf>
<functional> <mutex> <string>
<future> <new> <strstream>
The 26 headers related to C (C11) are:
<cassert> <cinttypes> <csignal> <cstdio> <cwchar>
<ccomplex> <ciso646> <cstdalign> <cstdlib> <cwctype>
<cctype> <climits> <cstdarg> <cstring>
<cerrno> <clocale> <cstdbool> <ctgmath>
<cfenv> <cmath> <cstddef> <ctime>
<cfloat> <csetjmp> <cstdint> <cuchar>
ISO/IEC 14882:2014 (C++14)
Provisional list of headers based on draft standard N3797 found at ISO/IEC JTC1/SC22/WG21 site. The data is from tables 14 and 15 in section 17.6.1.2 Headers, amended as noted below. Since the standard has not been published (as of 2014-09-21), this list is not yet definitive.
The 54 C++ headers in C++14 are:
<algorithm> <initializer_list> <numeric> <strstream>
<array> <iomanip> <ostream> <system_error>
<atomic> <ios> <queue> <thread>
<bitset> <iosfwd> <random> <tuple>
<chrono> <iostream> <ratio> <type_traits>
<codecvt> <istream> <regex> <typeindex>
<complex> <iterator> <scoped_allocator> <typeinfo>
<condition_variable> <limits> <set> <unordered_map>
<deque> <list> <shared_mutex> <unordered_set>
<exception> <locale> <sstream> <utility>
<forward_list> <map> <stack> <valarray>
<fstream> <memory> <stdexcept> <vector>
<functional> <mutex> <streambuf>
<future> <new> <string>
The 26 headers related to C (C11) are unchanged compared with C++11:
<cassert> <cinttypes> <csignal> <cstdio> <cwchar>
<ccomplex> <ciso646> <cstdalign> <cstdlib> <cwctype>
<cctype> <climits> <cstdarg> <cstring>
<cerrno> <clocale> <cstdbool> <ctgmath>
<cfenv> <cmath> <cstddef> <ctime>
<cfloat> <csetjmp> <cstdint> <cuchar>
There is one new header listed for C++14 compared to C++11, namely <shared_mutex>.
NB: The draft lists a number of the headers (<deque>, <istream>, <stdexcept>, <unordered_set>) twice. Also, 5 headers from C++11 are not listed in the tables in the draft, namely <exception>, <iterator>, <ratio>, <scoped_allocator>, and <thread>. Since §18.8 defines <exception>, §24 defines <iterator>, §20.11 defines <ratio>, §30 defines <thread>, and §30.4 defines <shared_mutex>, this is an example of why you should not trust the draft standards as being the final word — they contain errors.
ISO/IEC 14882:2017 (C++17)
Provisional list of headers in C++17 based on the draft N4659 dated 2017-03-21. This is a transcription of tables 16 and 17 from section 20.5.1.2 Headers. This is not the final standard; in theory, something could change.
There are 61 C++ headers:
<algorithm> <future> <numeric> <strstream>
<any> <initializer_list> <optional> <system_error>
<array> <iomanip> <ostream> <thread>
<atomic> <ios> <queue> <tuple>
<bitset> <iosfwd> <random> <type_traits>
<chrono> <iostream> <ratio> <typeindex>
<codecvt> <istream> <regex> <typeinfo>
<complex> <iterator> <scoped_allocator> <unordered_map>
<condition_variable> <limits> <set> <unordered_set>
<deque> <list> <shared_mutex> <utility>
<exception> <locale> <sstream> <valarray>
<execution> <map> <stack> <variant>
<filesystem> <memory> <stdexcept> <vector>
<forward_list> <memory_resource> <streambuf>
<fstream> <mutex> <string>
<functional> <new> <string_view>
The new headers compared to C++14 seem to be: <any>, <execution>, <filesystem>, <memory_resource>, <optional>, <string_view>, <variant>.
Again, the 26 headers related to C (C11) are unchanged compared with C++11 and C++14:
<cassert> <cinttypes> <csignal> <cstdio> <cwchar>
<ccomplex> <ciso646> <cstdalign> <cstdlib> <cwctype>
<cctype> <climits> <cstdarg> <cstring>
<cerrno> <clocale> <cstdbool> <ctgmath>
<cfenv> <cmath> <cstddef> <ctime>
<cfloat> <csetjmp> <cstdint> <cuchar>
See also What are the new features in C++17?
Note that some of the 'C library' headers are deprecated in C++17, specifically <ccomplex>, <cstdalign>, <cstdbool>, <ctgmath> (and not <ciso646>). The C++ header <codecvt> (added in C++11) is also deprecated in C++17.
* The 'off by one year' issues in the dates are due to the time it takes to process the standard after it is approved. ANSI approved the original C standard in 1989; ISO approved it in 1990. Amendment 1 was approved in 1994; it was released in 1995.
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.
http://www.cplusplus.com/reference/ lists all the standard C++ headers and the C++ wrappers of C header files.
tree.h is not part of the standard library.
I found this Wikipedia entry on the C standard library which contains, lists of C header files and detailed information on which standard they're part of. That gives you a nice historical perspective and some other, similar details.
Of course that's just C. There's a similar article to be found under "C++ standard library". That also has references to some other libraries which may not be "standard" per se but without which C++ would feel "crippled" to some people used to working with the extensions.
Related
I was getting SIGILL Runtime Error on one of my codes.
But then i noticed that just changing the libraries used made it run normally.
Previous code(throws Runtime Error on C++14):
#pragma GCC target("avx2")
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
Modified version(Gave AC on C++14):
#include<bits/stdc++.h>
What might be the reason for this?
I'm trying to use SRWLock with C++ project Visual Studio 2012 (Windows 7) targeting 32-bit Windows only and SRWLock is better then CriticalSections in my case.
As i've searched, i should include WinBase.h and use std namespace. But SRWLock is still undefined. Couldn't find anything useful on Google. What i'm missing? I appreciate any clues.
Code:
#include <cstdlib>
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <windows.h>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <conio.h>
#include <WinBase.h>
using namespace std;
SRWLock gLock; // here is the problem
Where was a mistype: Should be SRWLOCK instead of SRWLock.
And you need
#include <windows.h>
I am new to C++ and I am debugging one problem where there is a allocate.h file which is included by main.cpp file. Now the allocate.h file has first line like this : #include <memory.h>. and when I try to compile main.cpp I get an error message saying
Microsoft Visual Studio 11.0\ VC\ include\ typeinfo (153) : error
C2504 exception base class undefined
But when I change that first line to : #include <memory> then main.cpp compiles fine. Thats when I started to search the web for difference between these two styles of including files and I haven't found any detailed explanation yet. If anybody can explain the difference between including a .h file and a memory standard header, that would be really helpful.
Is it because #include<memory> is more thread safe ? or is it because its just the way in c++ to include files.
Also I am using cmake to include my project in the llvm's generated solution. When generating my .vcxproj file it includes _HAS_EXCEPTIONS=0; in the <PreprocessorDefinitions> tag in it. If I use the earlier declaration #include<memory.h> and remove _HAS_EXCEPTIONS=0; from the <PreprocessorDefinitions> tag then the project compiles fine. How is all this connected ? Can somebody help me connect the dots ?
<memory.h> and <memory> aren't different styles, they are two completely different headers.
<memory.h> looks like it's an internal header used by MS's C library, you shouldn't be including it, use the standard C++ header <memory>.
After writing this answer I found this SO question that I think is relevant.
This is nothing to do with thread safety AFAIK. The standard C++ headers are as below from the reference, 17.6.1.2 Headers:
Table 13 — C++ library headers
<algorithm> <fstream> <list> <regex> <typeindex>
<array> <functional> <locale> <set> <typeinfo>
<atomic> <future> <map> <sstream> <type_traits>
<bitset> <initializer_list> <memory> <stack> <unordered_map>
<chrono> <iomanip> <mutex> <stdexcept> <unordered_set>
<codecvt> <ios> <new> <streambuf> <utility>
<complex> <iosfwd> <numeric> <string> <valarray>
<condition_variable> <iostream> <ostream> <strstream> <vector>
<deque> <istream> <queue> <system_error>
<exception> <iterator> <random> <thread>
<forward_list> <limits> <ratio> <tuple>
As others have said, memory.h is not one of them.
For completeness, here are the C++ standard headers for C library facilities.
Table 14 — C++ headers for C library facilities
<cassert> <cfloat> <cmath> <cstddef> <ctgmath>
<ccomplex> <cinttypes> <csetjmp> <cstdint> <ctime>
<cctype> <ciso646> <csignal> <cstdio> <cuchar>
<cerrno> <climits> <cstdarg> <cstdlib> <cwchar>
<cfenv> <clocale> <cstdbool> <cstring> <cwctype>
Intellisense is broken with this code, everything is undefined to Intellisense from tree header:
#include "tree.h"
#include <iostream>
#include <ctime>
#include <string>
#include <list>
But when I move my own bst implementation header file down a bit, Intellisense starts working again.
#include <iostream>
#include <ctime>
#include <string>
#include <list>
#include "tree.h"
Why is this?
I have a cpp file contains this include:
#include "twitServer.h"
and in twitServer.h I have:
#ifndef twitServer_twitServer_h
#define twitServer_twitServer_h
#include <string>
#include <map>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <cstring>
#include <netdb.h>
#include <errno.h>
#include <sstream>
#include <algorithm>
#include <ctime>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "twitUser.h"
using namespace std;
void startServer(string port);
#endif
But the Xcode says for this line:
if ((rv = getaddrinfo(NULL, port, &hints, &ai)) != 0) {
fprintf(stderr, "selectserver: %s\n", gai_strerror(rv));
exit(1);
}
that the getaddrinfo is not defined... why that?
if the includes are in the cpp file it works fine how comes
Not sure how to fix your problem, but by convention, you should never include in the header file, because you might write code some day, needing your header file, but not all the includes.
Try including Ws2tcpip.h and see if that solves the problem. This is what MSDN has to say about it (see the requirements section)
http://msdn.microsoft.com/en-us/library/windows/desktop/ms738520%28v=vs.85%29.aspx
Also, let me say that this seems like an awful lot of header files included and some should not be matched unless you really know what you are doing. There are quite a bit of C++ headers (iostream (which is included twice by the way), cstdio, cstdlib, algorithm, list, string, ctime...) mixed with C headers (stdio.h, stdlib.h string.h). Maybe it's time for some late spring cleaning in there :)