Thread: C error ? who can tell me what to do ?

  1. #1
    Registered User actionbasti's Avatar
    Join Date
    Dec 2002
    Posts
    48

    C error ? who can tell me what to do ?

    Hello there,

    every time i compile and link my programs i get the following warning message :

    warning (line#): return type of 'main' is not 'int'.

    I am using the DJGPP compiler, could that be the reason?

    Thank you for your attention.

  2. #2
    Axolotl
    Guest
    Your main function should always return a type int

    int main()
    {
    program
    return 0; /* returns the int value */
    }

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    You probably have used

    void main (...)

    The type of main should be int. See Axolotl's example.

  4. #4
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Maybe in your main() function you've returned something that is not an integer... Post the code, so we can tell...
    none...

  5. #5
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    normally you can use void main(), but for compliance with ANSI and good programming practice, main should return int. This can inform the status of program termination to OS.
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >normally you can use void main()
    Only if your compiler supports such a declaration of main.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed