Function should have prototype?? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Function should have prototype??

cuongmitscuongmits Posts: 34Member
I have installed Turbo C++ 3.0 an tried to run it with the following program. But one mistake have appeared, and I dont know how to fix it. The comment of error: FUNTION _EXIT SHOULD HAVE A PROTOTYPE!! Maybe prob with compiler??

[code] #include
#include
#include
int main(){
clrscr();

/* request auto detection */
int gdriver = DETECT, gmode, errorcode;

/* initialize graphics mode */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */
{
cout << "Graphics error: %s
" << grapherrormsg(errorcode);
cout << "Press any key to halt:";
getch();
exit(1); /* return with error code */
}

circle(100,200,50);
// cout << "Hello world";
getch();
return 0;
} [/code]
«1

Comments

  • BodkinBodkin Posts: 100Member
    The [italic]exit()[/italic] method is defined in:
    [code]#include [/code]
  • cuongmitscuongmits Posts: 34Member
    [b][red]This message was edited by cuongmits at 2006-2-27 14:4:13[/red][/b][hr]
    : The [italic]exit()[/italic] method is defined in:
    : [code]#include [/code]
    :
    Thanks for you advice, but when I tried to add STDLIB.H, I got these errors:

    UNDEFINED SYMBOL _CIRCLE IN MODULE HELP.CPP (HELP.CPP my program)
    UNDEFINED SYMBOL _GRAPHERRORSMS IN MODELE HELP.CPP
    UNDEFINED SYMBOL _GRAPHRESULT IN MODULE HELP.CPP
    UNDEFINED SYMBOL _INITGRAPH IN MODULE HELP.CPP

    p/s this program I copy from documentation of TURBO C++ 3.0, it must work or there is problem with compiler or installation (?)


  • HK_MP5KPDWHK_MP5KPDW Posts: 770Member ✭✭✭
    : [b][red]This message was edited by cuongmits at 2006-2-27 14:4:13[/red][/b][hr]
    : : The [italic]exit()[/italic] method is defined in:
    : : [code]#include [/code]
    : :
    : Thanks for you advice, but when I tried to add STDLIB.H, I got these errors:
    :
    : UNDEFINED SYMBOL _CIRCLE IN MODULE HELP.CPP (HELP.CPP my program)
    : UNDEFINED SYMBOL _GRAPHERRORSMS IN MODELE HELP.CPP
    : UNDEFINED SYMBOL _GRAPHRESULT IN MODULE HELP.CPP
    : UNDEFINED SYMBOL _INITGRAPH IN MODULE HELP.CPP
    :
    : p/s this program I copy from documentation of TURBO C++ 3.0, it must work or there is problem with compiler or installation (?)
    :
    :
    :

    [blue]Are those functions declared in the graphics.h header? Or... are those linker errors? If they are linker errors and not compiler errors, have you added the appropriate library to your project settings? It may not be (probably isn't) one that is included in default projects.[/blue]

  • cuongmitscuongmits Posts: 34Member
    : : [b][red]This message was edited by cuongmits at 2006-2-27 14:4:13[/red][/b][hr]
    : : : The [italic]exit()[/italic] method is defined in:
    : : : [code]#include [/code]
    : : :
    : : Thanks for you advice, but when I tried to add STDLIB.H, I got these errors:
    : :
    : : UNDEFINED SYMBOL _CIRCLE IN MODULE HELP.CPP (HELP.CPP my program)
    : : UNDEFINED SYMBOL _GRAPHERRORSMS IN MODELE HELP.CPP
    : : UNDEFINED SYMBOL _GRAPHRESULT IN MODULE HELP.CPP
    : : UNDEFINED SYMBOL _INITGRAPH IN MODULE HELP.CPP
    : :
    : : p/s this program I copy from documentation of TURBO C++ 3.0, it must work or there is problem with compiler or installation (?)
    : :
    : :
    : :
    :
    : [blue]Are those functions declared in the graphics.h header? Or... are those linker errors? If they are linker errors and not compiler errors, have you added the appropriate library to your project settings? It may not be (probably isn't) one that is included in default projects.[/blue]
    :
    :
    Yes, those functions declared in the graphics.h header.
    I dont know about error with linker, my directories are:
    C:TCINCLUDE (include directories)
    C:TCLIB (library directories)
    (these links are automatically declared when I installed)

    [quote] have you added the appropriate library to your project settings? [/quote] >> how to do it?

    I doubt the process of installation maybe problem there when I tried to install TURBO C++ 3.0 without reading readme file (?)

    Thank you.
  • LundinLundin Posts: 3,711Member
    : : : [b][red]This message was edited by cuongmits at 2006-2-27 14:4:13[/red][/b][hr]
    : : : : The [italic]exit()[/italic] method is defined in:
    : : : : [code]#include [/code]
    : : : :
    : : : Thanks for you advice, but when I tried to add STDLIB.H, I got these errors:
    : : :
    : : : UNDEFINED SYMBOL _CIRCLE IN MODULE HELP.CPP (HELP.CPP my program)
    : : : UNDEFINED SYMBOL _GRAPHERRORSMS IN MODELE HELP.CPP
    : : : UNDEFINED SYMBOL _GRAPHRESULT IN MODULE HELP.CPP
    : : : UNDEFINED SYMBOL _INITGRAPH IN MODULE HELP.CPP
    : : :
    : : : p/s this program I copy from documentation of TURBO C++ 3.0, it must work or there is problem with compiler or installation (?)
    : : :
    : : :
    : : :
    : :
    : : [blue]Are those functions declared in the graphics.h header? Or... are those linker errors? If they are linker errors and not compiler errors, have you added the appropriate library to your project settings? It may not be (probably isn't) one that is included in default projects.[/blue]
    : :
    : :
    : Yes, those functions declared in the graphics.h header.
    : I dont know about error with linker, my directories are:
    : C:TCINCLUDE (include directories)
    : C:TCLIB (library directories)
    : (these links are automatically declared when I installed)
    :
    : [quote] have you added the appropriate library to your project settings? [/quote] >> how to do it?
    :
    : I doubt the process of installation maybe problem there when I tried to install TURBO C++ 3.0 without reading readme file (?)
    :
    : Thank you.
    :


    Been ages sence I did anything with BGI... you can try:

    - Options->Linker->Libraries->Graphics Library should be marked
    - If it doesn't help, add the file EGAVGA.BGI to the project. It is located in the TCgi folder.
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [blue]Why the error messages are in uppercase?
    I think the problem may be deeper than missing libraries.
    [/blue]
  • cuongmitscuongmits Posts: 34Member
    : [blue]Why the error messages are in uppercase?
    : I think the problem may be deeper than missing libraries.
    : [/blue]
    :
    Thank everyone so much for your help. I have copied every files in CLASSLIB into INCLUDE and LIB and my proga did work perfectly. The reason maybe is there was not stdlib or other libraries, when I tried to change line EXIT(1); to RETURN 1; then program dont need to include stdlib.

    Till now I dont know why people separate folders CLASSLIB and INCLUDE, LIB in TURBRO C++ 3.0??

    Once again, thanks so much!!
  • antrockzantrockz Posts: 1Member
    : I have installed Turbo C++ 3.0 an tried to run it with the following
    : program. But one mistake have appeared, and I dont know how to fix
    : it. The comment of error: FUNTION _EXIT SHOULD HAVE A PROTOTYPE!!
    : Maybe prob with compiler??
    :
    : [code]: #include
    : #include
    : #include
    : int main(){
    : clrscr();
    :
    : /* request auto detection */
    : int gdriver = DETECT, gmode, errorcode;
    :
    : /* initialize graphics mode */
    : initgraph(&gdriver, &gmode, "");
    :
    : /* read result of initialization */
    : errorcode = graphresult();
    :
    : if (errorcode != grOk) /* an error occurred */
    : {
    : cout << "Graphics error: %s
    " << grapherrormsg(errorcode);
    : cout << "Press any key to halt:";
    : getch();
    : exit(1); /* return with error code */
    : }
    :
    : circle(100,200,50);
    : // cout << "Hello world";
    : getch();
    : return 0;
    : } [/code]:



    Soln: exit() function is defined in <process.h>.


  • LundinLundin Posts: 3,711Member
    The thread is 2 years old...

    And process.h doesn't exist in ISO C nor ISO C++, it is a non-standard header. exit() is found in stdlib.h.
«1
Sign In or Register to comment.