Archived

This topic is now archived and is closed to further replies.

d98mp

glut + bcc32 + fstream => compile error

Recommended Posts

d98mp    122
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

Share this post


Link to post
Share on other sites
Palidine    1315
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

Share this post


Link to post
Share on other sites
Fruny    1658
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 ]

Share this post


Link to post
Share on other sites
d98mp    122
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

Share this post


Link to post
Share on other sites
IndirectX    122
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]

Share this post


Link to post
Share on other sites
Fruny    1658
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 ]

Share this post


Link to post
Share on other sites
d98mp    122
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

Share this post


Link to post
Share on other sites