views:

55

answers:

1

hey guys This code compiles fine in Vc++ but in borland c++ gives me this error.. Please help me out.. The code has no syntax errors and works fine.. Seems like there is a problem with the header.. But these are the standard headers and library files

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
main.c:
Error E2337 c:\Borland\Bcc55\include\glut\glut.h 146: Only one of a set of verloadedfunctions can be "C"
+3  A: 

Hi Ram,

The error is due to overloaded functions being treated like C-language functions. Because the language "C" has no overloading it can only have one function of a given name. Apparently GLUT has a function that has the same name as some other function in the program. This may be your own function (just check the glut.h line (146 or thereabouts) to see if you've duplicated a name. Your main.c is a "C" program so this will force C-language compilation (unless you've forced C++ compilation with a command line switch). You might try renaming your code to "main.cpp" and recompiling.

Another possibility is the DEFINES are not set up to include GLUT properly and GLUT itself is trying to define overloaded functions with the same name. This is probably pretty unlikely as I think that GLUT is compile-able in "C".

Here's a piece of code that will force the error so you can see why it happens. Just switch the commenting around on the second "somefunc" subroutine. Save this code as C++ (ie. myfile.cpp).

//
// Program myfile.cpp
//

#include <stdio.h>

extern "C" float somefunc(int a) { return(a); };

// Un-comment one of the following two lines.
extern "C" float somefunc(float a) { return(a); };  // This line should produce the error.
// float somefunc(float a) { return(a); };          // This line should compile.


void main(void){
    printf("Hello World!\n");
}

Good luck,

/Alan

Alan
thanks a ton! problem was with the exit fn in glut and stdlib..
Ram Bhat