[sdiy] int-main VS void-main....To C or not to C that's the question! Or C are ice cream in hell! :-)

Jason Proctor jason at redfish.net
Wed Jan 12 21:40:12 CET 2011


>  >Jason Tribbeck <jason at tribbeck.com>:
>>'re doing embedded development, then typically your main() won't
>>return at all (it'll sit in an endless loop somewhere), so void
>>main(void) is the order of the day.
>
>Ok, but when i do void main(void) the C30 compilator barks and says
>not int but compiles. When i do int main() it does not bark and
>compile and when i do main() it barks says assumes int and compiles.
>Ice cream in Hell! :-)

does the C standard specify that main() should be defined to return 
int and take argc and argv? regular C only has function name symbols 
as opposed to name & encoded parameters & const etc, so your function 
will be called anyway regardless of what parameters you specify. i 
suppose your environment might define which if any parameters main() 
takes, so it would be prudent to include those to guard against 
warnings etc.

in an environment where main() is expected to return, it returns the 
return code from the program, which shells etc *will* take note of. 
either way i *think* it *should* be defined to return int, whether 
your environment takes any notice of it...

>
>>C isn't that hard: void (*(*f[])())() defines f as an array of 
>>unspecified >size, of pointers to functions that return pointers to 
>>functions that >return void 
>
>sorry, have no idea what your talking about.

the rule about reading function pointer declarations is to read them 
backwards, or inside out :-)





More information about the Synth-diy mailing list