Simple question about preprocessors on emacs

Hello!
I am using emacs editor and compiling through terminal on Mac OS X 10.6.7 in my learning of C++. I am using the book Teach Yourself C++ by Richard Riley as a reference.

My question is: When I compile using the preprocessor
#include <iostream.h>
(as my book always uses) there is always the error saying I need to look at the list of compatible preprocessors.

Instead I use
#include <iostream>
using namespace std;

Which works just fine.


I suppose that emacs doesn't have the iostream.h file???
Why does the second work and not the first?
Is my book outdated?

Thank you
emacs is a text editor. emacs is not a C++ compiler. You use emacs to write the text file, and then a separate programme, called the compiler, takes that text file and compiles it. Usually, a preprocessor runs on the file first, and as part of its operations, replaces everything you #include in the file with a big block of text it finds somewhere else.

iostream.h is the old name for the header. If your preprocessor complains about not being able to find it, it's because you're using a recent system that doesn't support it. Well done. Stop using iostream.h, use iostream.

Last edited on
Then why the need for the
using namespace std; ?

and where can I find the list of supported preprocessors?
Last edited on
Then why the need for the
using namespace std; ?


To make available the contents of the namespace called std. There are other ways to use functions and variables that are in the std namespace. using namespace std; is something of blunt instrument, but it does the job. It has nothing whatsoever to do with the modern C++ standard header naming style. Some old versions of standard headers did not use namespaces, so it was not necessary to declare that one was using a namespace.

Is my book outdated?


I expect so.


Last edited on
Topic archived. No new replies allowed.