#Stream.h Error?
2 messages in this thread
Anyone:
While trying to learn C++ I ran the small sample program on page 146 of Rhodes
& McKeehan's book "Symantec C++ Programming for the Macintosh". The program
starts off with a #include <stream.h>.
When compiling this program I get an syntax error on line 7 of stream.h:
extern "C++" {
I can't believe there is an error in stream.h. Could I be doing something
wrong?
The program also includes:
long startTime = TickCount();
int total = 0;
int i;
for (i= 0; i < 100000; i++)
{
total += Value(i);
}
long finishTime = TickCount();
Here I get a Syntax error for the endTime = statement. I can see no reason for
this error – am I missing something
Thanks in advance from a novice programmer.
Dennis
Dennis,
One way or another, you are compiling C++ code using the C compiler. Make
sure you name your file with an extension which is being mapped to the C++
translator. [See the extensions page of the TPM preferences to see which
translator the .cp extension is going to, or use .cpp to be (reasonably) sure.]
The syntax error in stream.h results from the string "C" following the
extern…C doesn't expect a string literal there. The syntax error on the
long finishTime = TickCount ();
(or is it endTime???) line comes because C is not expecting a declaration
there, since it has already seen code statements in the scope.
–John