Pages: 1 [2]   Go Down
Author Topic: Is it possible to end a program forcefully?  (Read 710 times)
0 Members and 1 Guest are viewing this topic.
Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
When I give my function declaration or definition is there any difference whether or not I put void in the parameter list or if I just use empty parenthesis?  I know both will compile.  But is there any larger reason to put the second void in there in the definition or declaration?

Unfortunately I'm far from being a C/C++ expert, I like hardware much better. I think the use of void function_name(void) is the formal method but void function_name() seems to be an acceptable default. I would bet that varies with the C/C++ standard the compiler is working with and most likely has changed over time and newer compiler standards. But wait for a real expert to know for sure. In the mean time use what works is my motto.  smiley-grin

Lefty
Logged

Offline Offline
Edison Member
*
Karma: 17
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the abort function is exactly what OP is looking for. It's a library function that does essentially what the stopSketch() function posted does.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But is there any larger reason to put the second void in there in the definition or declaration?
The void in the parentheses after the function name says that you have thought about the list of arguments, and have decided that there are none, so you are explicitly telling the compiler that.

The empty set of parentheses implicitly says that there are no arguments. The resulting object module is exactly the same.
Logged

Pages: 1 [2]   Go Up
Jump to: