[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Newbie - should this work?
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] Newbie - should this work? |
Date: |
Tue, 21 Jan 2003 17:41:09 +0100 (MET) |
Tom Harris <address@hidden> wrote:
> The docs for -ffreestanding do not seem to mention any effect on
> main(),
Then you must have a different man page than I:
-ffreestanding
Compile for a freestanding environment; this im-
plies the `-fno-builtin' option, and implies that
main has no special requirements.
In a hosted environment, the only prototypes for main() that are
allowable are
int main(void);
int main(int, char **);
(and compatible, namely char ** can be expressed in another way, too).
In a freestanding environment, main() is no longer special, so any
prototype for it is allowable.
I have writte a few lines about the effect of -ffreestanding in the
avr-libc docs. You might want to read it, there are more side effects
than you mention (which influence optimization).
> I always have main() returning void (in an embedded system, where
> would main() return to?), ...
There is not much point in this method (i. e., i'd consider it a cruel
hack to "fix" it by supressing a warning), and it will fail to work in
a C++ environment where the compiler insists on a correctly declared
main(). If you write something like:
int
main(void)
{
...
for (;;) {
/* program main loop */
...
}
return 0;
}
you are fully compliant with the C standard, and the optimizer will
eliminate the trailing "return 0;" anyway because it is unreachable.
All serious MCU programs will certainly have their own main loop, so
this should never become a real problem.
--
J"org Wunsch Unix support engineer
address@hidden http://www.interface-systems.de/~j/
avr-gcc-list at http://avr1.org
- Re: [avr-gcc-list] Newbie - should this work?, (continued)
Re: [avr-gcc-list] Newbie - should this work?, Josh Thompson, 2003/01/26
Re: [avr-gcc-list] Newbie - should this work?, Volkmar Dierkes, 2003/01/18
RE: [avr-gcc-list] Newbie - should this work?, Tom Harris, 2003/01/26
- Re: [avr-gcc-list] Newbie - should this work?,
Joerg Wunsch <=
Re: [avr-gcc-list] Newbie - should this work?, Christoph Plattner, 2003/01/26