+ Reply to Thread
Results 1 to 2 of 2

Thread: Why is different warning/error while not returning an value?

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    23

    Why is different warning/error while not returning an value?

    I am using VC++ and am getting different behavior on return value from a function.

    While compiling below function it raises just a warning.

    Code:
    int main(int argc, char* argv[])
    {
    }
    While compiling below function it raises an error.

    Code:
    int GetValue()
    {
    
    }

    Why is this different behavior?

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    29
    If you see carefully at the warning rose by compiler for main procedure:

    It is : "warning C4508: 'main' : function should return a value; 'VOID' RETURN TYPE ASSUMED"

    It means compiler uses "void" as return type.

    This is not possible with GetValue as it is not special function (like main) that compiler already knows about.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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