main is void, but gcc thinks it's an int...


Results 1 to 4 of 4

Thread: main is void, but gcc thinks it's an int...

  1. #1
    Join Date
    Mar 2002
    Location
    Nashville, TN, USA
    Posts
    12

    main is void, but gcc thinks it's an int...

    I keep getting the following error (compiling using 'g++ assignment4.cpp')

    assignment4.cpp:22: `main' must return `int'
    assignment4.cpp: In function `int main(...)':

    and main is void!

    Code:
     void main(void)
    {
    Any ideas as to what's wrong with my gcc settings or my code?
    Pythonista in training
    HelicalCynic
    Bryan Bates

  2. #2
    Join Date
    Jan 2000
    Location
    Houston, TX, USA
    Posts
    9,994
    C++ standard dictates that main must return an int, so I guess it is changing it for you in memory
    We love Sensei!!
    A 1:1 ratio of Arby's sauce to Horsey sauce must be maintained.
    Like Linux? Want to like it more? Try Debian
    Best. (Python.) IRC bot. ever.
    Geekology

  3. #3
    Join Date
    Mar 2000
    Posts
    427
    that's strange. i was just able to do that.
    it does warn that it has changed the return type, but compiles if the -Wall option is not used during the compile

    i'm willing to bet the answer for all of this lies somewhere in the specs file.
    run gcc -v to find your specs file.

    is there a reason main needs to return void in your program?

    [ 27 March 2002: Message edited by: binaryDigit ]

  4. #4
    Join Date
    Mar 2002
    Posts
    106
    do this

    int main()
    {
    blah;
    return 0;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •