std Namespace
g++ and CC -E option runs your code through the
preprocessor and nothing else.
#include "include-file-name"
#include <include-file-name>
< > and "" have different search paths.
< > usually searches only the system directories.
" " searches other directories first, then system directories.
" " searches . (the current directory).
-I Option-I compiler command-line option manipulates the " " search
paths.
< > search paths.
g++ and CC.
g++ -Imylib ...
./mylib, then ., then, ...
-I options are cumulative.
g++ -Iliba -Ilibb ... searches liba, then libb then ...
< > search path
too.
g++ support for this is too ugly to talk about.
#ifndef idiom for include files.
#ifndef _includefile_h_ #define _includefile_h_ // Included material here. #endif
.h, .hh, .H, .hxx
.h
.h standard includes.
<string> is not <string.h> is not <cstring>
/ vs. \.
std Namespacestd namespace.
std::.
using declarations make this less cumbersome.
std:: is useful documentation.
std:: or explicitly eliminate it.
using namespace x.
<iostream>, <iomanip>, <fstream>
<vector>, <list>, <map>, <iterator>,
<algorithm>, <utility>, <queue>, <stack>,
<deque>, <set>, <bitset>, <functional>,
<memory>
<exception>, <stdexcept>
<string>, <sstream>
<strstream> (it's deprecated).
<locale>, <limits>, <typeinfo>
std namespace, sometimes.
.h and prepend a 'c'.
assert.h, use
#include <cassert>
.h forms from C++ is nonstandard.
c-prepended headers make the proper C++ extern
declarations, .h headers do not.
<cassert>.
assert((0 <= i) and (i < N));
assert()'s a macro, no std::.
<cctype>.
ch = std::toupper(ch);
<cmath>.
double x = std::log(M_PI);
M_PI is a macro, log() is a function; std::M_PI doesn't compile.
<climits>.
cout << "Biggest int is " << INT_MAX << "\n"
std::INT_MAX doesn't compile either.
<ctime>.
strcasecmp(), strings.h, X Window System includes.
#include source (.cc) files, but the STL does.
c prefix too.
This page last modified on 8 September 2003.