Philip Lantz <> writes:
> Keith Thompson wrote:
>> Philip Lantz <> writes:
>> > Keith Thompson wrote:
>> >> Tim Rentsch writes:
>> >> > Keith Thompson writes:
>> >> >> Yes, I'm assuming that a given compiler knows what forms of main
>> >> >> are supported by that compiler.
>> >> >
>> >> > I simply disagree with the assumption. I think it's much harder
>> >> > than you seem to think it is.
>> >>
>> >> It would be helpful if you could cite a specific implementation where
>> >> this would be at all difficult. I've never encountered one.
>> >
>> > I use GCC to generate code for both a standard Linux platform, and for
>> > an embedded system. I use the exact same GCC for both cases. In the
>> > latter case, main is called by startup code that I have written in
>> > assembly language. GCC has *no idea whatsoever* what forms of main will
>> > work and which will cause undefined behavior. I doubt very much that
>> > this is an uncommon situation. How do you think GCC could be made to
>> > issue the warning that you suggest should be required?
>>
>> When you say you use the exact same GCC, does that imply that you could
>> take an object file generated by the GCC you're using and use it either
>> on the Linux platform or on the embedded system? If so, that's not what
>> I would have expected.
>
> Yes. I'm not sure I've ever done this, so I can't swear that there
> aren't differences in compiler invocation that would make the object
> files incompatible, but I don't think that there are; and if there were
> any reason to share object files between the two, I think it could be
> done without much effort.
Interesting.
Then that would be a valid case where it could be difficult for
a compiler to warn about an unsupported definition of main().
I suppose it could still be checked at link time, but requiring
that might be a but much.
That would be the only excuse I can think of for not warning about
a definition of main() that's not supported on the current system.
As I think I mentioned elsethread, gcc warns about "void main(void)",
at least on my system. Does your embedded target permit "void
main(void)", and does gcc (incorrectly) warn you about it when you
compile for it?
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"