| |||
Home > Mixing C, C++, and Assembly Language > Using C header files from C++ > Including system C header files |
You do not have to take any special steps to include standard
system C header files, such as stdio.h
. The
standard C header files already contain the appropriate extern
"C"
directives. For example:
#include <stdio.h> int main() { ... // C++ code return 0; }
If you include headers using this syntax, all library names are placed in the global namespace.
The C++ standard specifies that the functionality of the C
header files is available through C++ specific header files. These
files are installed in
,
together with the standard C header files, and can be referenced
in the usual way. For example:install_directory
\RVCT\Data\3.0\build_num
\include\platform
#include <cstdio>
In ARM C++, these headers #include
the
C headers. If you include headers using this syntax, all C++ standard
library names are defined in the namespace std
,
including the C library names. This means that you must qualify
all the library names by using one of the following methods:
specify the standard namespace, for example:
std::printf("example\n");
use the C++ keyword using to import a name to the global namespace:
using namespace std;
printf("example\n");
use the compiler option --using_std
.