[SDL] Linker says: "undefined reference to `SDL_main' in SDL_windows_main.o?

Andre D andre at andred.ca
Wed Oct 2 01:05:59 PDT 2013


I _may_ be wrong on this, but I believe ansi C has implicit int, C99 does not.

On Wed, Oct 2, 2013 at 4:05 AM, Andre D <andre at andred.ca> wrote:
> Ah, I understand now, yes, implicit int return type is historically
> wonky.  If main() works it is not defining a void return type, it is
> defining an implicit int return type and might not work everywhere
> following modern standards (I think -Wreturn-type warns).
>
> On Wed, Oct 2, 2013 at 4:02 AM, Vittorio Giovara
> <vittorio.giovara at gmail.com> wrote:
>> On Wed, Oct 2, 2013 at 9:57 AM, Andre D <andre at andred.ca> wrote:
>>> From the spec:
>>>
>>> 5.1.2.2.1 Program startup
>>> The function called at program startup is named main. The
>>> implementation declares no
>>> prototype for this function. It shall be defined with a return type of
>>> int and with no
>>> parameters:
>>> int main(void) { /* ... */ }
>>> or with two parameters (referred to here as argc and argv, though any
>>> names may be
>>> used, as they are local to the function in which they are declared):
>>> int main(int argc, char *argv[]) { /* ... */ }
>>> or equivalent;9) or in some other implementation-defined manner.
>>>
>>> On Wed, Oct 2, 2013 at 3:55 AM, Andre D <andre at andred.ca> wrote:
>>>>> "Is valid" no, "works" maybe, it's quite compiler dependent.
>>>>
>>>> Incorrect: int main(void) is in C90 and C99 spec even.
>>
>> Umh that's what I said, "int main(void)" is fine, "main()"  is not, AFAIK.
>>
>> Vittorio
>>
>>>>
>>>> On Wed, Oct 2, 2013 at 3:52 AM, Vittorio Giovara
>>>> <vittorio.giovara at gmail.com> wrote:
>>>>> On Wed, Oct 2, 2013 at 7:57 AM, Sik the hedgehog
>>>>> <sik.the.hedgehog at gmail.com> wrote:
>>>>>> In C even just main() (without any types) is valid.
>>>>>
>>>>> "Is valid" no, "works" maybe, it's quite compiler dependent.
>>>>>
>>>>>> This is really just a side-effect of main being remapped as a macro to
>>>>>> SDL_main which of course doesn't have the flexibility of the real
>>>>>> main, so it's stuck with a single possible prototype. This ended up
>>>>>> biting me because I was using const char **argv instead of char **argv
>>>>>> (despite the fact that ABI-wise they were identical).
>>>>>
>>>>> Surprisingly I've seen this breakage many times on windows/mingw, but
>>>>> rarely on unix.
>>>>>
>>>>> Vittorio
>>>>> _______________________________________________
>>>>> SDL mailing list
>>>>> SDL at lists.libsdl.org
>>>>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>>> _______________________________________________
>>> SDL mailing list
>>> SDL at lists.libsdl.org
>>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>> _______________________________________________
>> SDL mailing list
>> SDL at lists.libsdl.org
>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



More information about the SDL mailing list