glut + bcc32 + fstream => compile error

Started by
5 comments, last by d98mp 21 years, 10 months ago
I try to compile my 3D game (which works perfectly in UNIX) at a Windows 2000 computer using Borland''s free compiler. In the program I include fstream.h. (I''ve got some small example programs which are compileable until I include fstream.h) I get this error: Error E2337 c:\Borland\Bcc55\include\gl/glut.h 141: Only one of a set of overloaded functions can be "C" I can''t be the only one having this problem... any solutions? /Mattias
/Mattias
Advertisement
1) please delete one of your posts.

2) my version of borland doesn''t have glut.h. make sure you actually have that file in the path specified. it may require a specific library installation. also looks like you might want to try using a \ instead of a / in the path name for your include call.

-me
You have a function which is declared as a C function but is overloaded. C doesn''t support overloading.


  extern "C"{  int foo (int);  int foo (double);}  


Or, look if your source file was created with a ''.c'' extension (compiled as C code by default).

Finally, and most importantly : DO NOT USE <fstream.h>, use <fstream>. fstream.h and iostream.h are the headers for the old iostream library. Otherwise I''ll have to use my 1337 H4X0RZ 5K177Z to correct your code myself

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
My apologize on posting the same topic twice. I blame it on my web browser.

Fruny:

glut.h or ifstream.h has the overloaded C function. My file is a .cpp-file (though it has no C++ features except for the IO). My glut version is 3.7 and I installed the OpenGL files according to the article references by opengl.org

This feels a bit off-topic, but I''m desperate: When I remove .h and include instead the compiler can''t find cout, endl or ifstream.
What shall I do?

This is very frustrating because my game compiled in UNIX and in Windows with Visual C++... :-(


/Mattias
/Mattias
quote:Original post by d98mp
When I remove .h and include instead the compiler can't find cout, endl or ifstream.


Either put

using namespace std;

after you include your headers, or prefix standard things with std:: like so:

std::cout << "Hello world";

Standard headers define their contents in namespace std.

[edited by - IndirectX on June 6, 2002 6:22:28 PM]
---visit #directxdev on afternet <- not just for directx, despite the name
glut.h or ifstream.h has the overloaded C function.

Which function is it ?

When I remove .h and include instead the compiler can''t find cout, endl or ifstream.

As indicated above, add using namespace std at the top of your .cpp files.

And your error messages could indeed be useful.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Now I''ve tried many different combinations. I get the error message on every combination of include files with or without .h.

If I include glut.h first I get an error in stdlib.h "(using std::exit"

If I include fstream.h first I get an error in glut.h "(extern _CRTIMP void __cdecl exit(int)"

It seems that the overloaded function is exit.
(I have to write std:: before calling exit(int) here, but at UNIX/Visual C++ I didn''t have to.)

using namespace std; didn''t work either, I got "undefined symbol cout" when I tried to use it.



/Mattias
/Mattias

This topic is closed to new replies.

Advertisement