[sdiy] int-main VS void-main....To C or not to C that's the question! Or C are ice cream in hell! :-)
Tim Daugard
daugard at cox.net
Wed Jan 12 22:55:05 CET 2011
From: "Jason Proctor" <jason at redfish.net>
>> >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.
> 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
Yes. In my persuit of programing the MSP430 series of chips using TI's
CCS I've run into numerous headaches.
After listening here and other research . . .
int main (void)
{
. . .
return 0;
}
is the start and end of my main routine code.
int main (. . . ) is the C++ standard (and apparently
the C standard) early compiliers tolerated
void main (but it was wrong)
> 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.
As far as the main (arguments) goes main (void) works fine and as it
is an embedded system if anything passes arguments to main something
strange is going on.
> 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...
agreed.
And now for all you experts why won't this work??
#include <processor.h> // TI's header
#ifdef __has_xxx // included in the header file
#include xxxx.h
#endif
for some reason I can't get CSS to process a definition from
the header file that starts with a double underscore. All
my other #ifdef(s) work fine. I even tried redefining the
double inderscore to a single underscore.
Tim Daugard
AG4GZ 30.4078N 86.6227W Alt: 12 feet above MSL
http://members.cox.net/synthfred/h_toctop.htm (Fred's online edition)
More information about the Synth-diy
mailing list