Posted by
April 25th, 2014 12:37 pm

extern int main();

Has anyone of you ever utilitized this line of code?
Cause I just did. Lulz.

One Response to “chaos++”

  1. laaph says:

    sejong:tmp stanza$ cat extern.c

    sejong:tmp laaph$ cat > extern.c
    extern int main();
    sejong:tmp laaph$ gcc -Wall extern.c
    Undefined symbols for architecture x86_64:
    “_main”, referenced from:
    start in crt1.10.6.o
    ld: symbol(s) not found for architecture x86_64
    collect2: ld returned 1 exit status
    sejong:tmp laaph$

    Right, you made a function declaration for main(), but no definition. If I add elsewhere
    int main() {}

    it works.

    sejong:tmp laaph$ gcc -Wall extern.c
    extern.c: In function ‘main’:
    extern.c:2: warning: control reaches end of non-void function

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]