[SDL] error msg

Steve Salkin steve at salkin.org
Tue Feb 5 19:20:01 PST 2002


> Bob Pendleton wrote:
>  Here is a little .h file that I have been using in various forms
since,
> oh, around 1982...
[snip comment block]
> 
> #ifdef __cplusplus
> #include <stdio.h>
> #include <stdlib.h>
> #include <fstream.h>
> 
> #define trace() (cout << (__FILE__) << "@" << (__LINE__) << endl <<
> flush);
> #else
> #include <stdio.h>
> #include <stdlib.h>
> #define trace() printf("%s@%d\n", __FILE__, __LINE__);
> #endif
> 
> #endif

In 1982 this was fine, but now you'll probably want std::cout and
std::endl in the C++ macro. Also it would probably be better to include
<cstdio> and <cstdlib> rather than <stdio.h> and <stdlib.h> in the C++
version. If you want fstream, it should be <fstream>, but, you probably
don't actually want that. It is built on <iostream>, and you're not
using anything in <fstream>. <iostream> contains the declarations for
cout and cin.

The C looks good though. :)

HTH,

S-





More information about the SDL mailing list