Author Topic: MingW: error: to few arguments to function 'void exit(1);  (Read 21705 times)

Offline laserbeak43

  • Multiple posting newcomer
  • *
  • Posts: 61
MingW: error: to few arguments to function 'void exit(1);
« on: August 17, 2007, 07:05:56 am »
hi,
i know that this is probalby the wrong place to post this, but i'm in the mingw chatroom on irc and it's pretty dead.

i'm getting an error, that says"error: to few arguments to function 'void exit(1)'" can someone please help me with this one?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: MingW: error: to few arguments to function 'void exit(1);
« Reply #1 on: August 17, 2007, 08:51:27 am »
It is the wrong place, we're not a general programming forum.

But anyway, your error says just what it says: you use too few arguments (i.e. none at all).

Write exit(0); instead of exit(); and it will work.

Google man 2 exit for reference.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline laserbeak43

  • Multiple posting newcomer
  • *
  • Posts: 61
Re: MingW: error: to few arguments to function 'void exit(1);
« Reply #2 on: August 17, 2007, 08:53:00 am »
thanks i'll do that. cause the code i'm reading is telling me to type exit(1)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: MingW: error: to few arguments to function 'void exit(1);
« Reply #3 on: August 17, 2007, 08:56:41 am »
That will work too, just exit() will not.

The function (found in stdlib.h) is void exit(int), i.e. it takes exactly one integer, which is returned as the exit code of your program (0 is standard for "no error"). The function does not return, obviously.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline laserbeak43

  • Multiple posting newcomer
  • *
  • Posts: 61
Re: MingW: error: to few arguments to function 'void exit(1);
« Reply #4 on: August 17, 2007, 08:58:16 am »
maybe it's cause i haven't cleaned the project before i re rean it... cause i use exit(1)

nope... no luck...

could it be because the code that i'm writting is C in a C++ project? wouldn't codblocks pick this up and use the necessary compiler?
« Last Edit: August 17, 2007, 09:03:50 am by laserbeak43 »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: MingW: error: to few arguments to function 'void exit(1);
« Reply #5 on: August 18, 2007, 09:28:10 pm »
maybe it's cause i haven't cleaned the project before i re rean it... cause i use exit(1)

nope... no luck...

could it be because the code that i'm writting is C in a C++ project? wouldn't codblocks pick this up and use the necessary compiler?

Code::Blocks using MinGW GCC decides based on file extension. Is the file extension .c or .cpp?

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline laserbeak43

  • Multiple posting newcomer
  • *
  • Posts: 61
Re: MingW: error: to few arguments to function 'void exit(1);
« Reply #6 on: August 19, 2007, 04:24:20 am »
maybe it's cause i haven't cleaned the project before i re rean it... cause i use exit(1)

nope... no luck...

could it be because the code that i'm writting is C in a C++ project? wouldn't codblocks pick this up and use the necessary compiler?

Code::Blocks using MinGW GCC decides based on file extension. Is the file extension .c or .cpp?

Tim S

yeah i made a .cpp file to follow the book that i'm reading. it's funny cause the book tells me i need to know c++. i'll change it and see w hat happens.

in the advanced properties section, i changed the compiler options to C instead of CPP and it built itself so far. no i just gotta figure out what looks to be like a linker error to confirm it's working.