Multiple Function Return Types

This is a discussion on Multiple Function Return Types within the C++ Programming forums, part of the General Programming Boards category; Hello people and sorry for the simple question: I am taking a Win32 API programming tutorial and have came across ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    45

    Multiple Function Return Types

    Hello people and sorry for the simple question:

    I am taking a Win32 API programming tutorial and have came across the following function definitions:

    int WINAPI WinMain
    --and--
    LRESULT CALLBACK WndProc

    Now, what i do not understand is the function definition. I know functions to be of similarity to the following:

    Code:
    return-type function-name(args)
    {
                // Some functional code
                
                return var;  // Where var is a value of type return-type
    }

    Please tell me if I am wrong in that thinking. Now the functions i mentioned have two words where return-type should be: ????? Why is this . Does this mean that the function can return two values or that there must be some sort of typecasting. Please help me in this simple problem

    Thanks in advance for any help that you can offer,
    mintsmike

  2. #2
    Student legit's Avatar
    Join Date
    Aug 2008
    Location
    UK -> Newcastle
    Posts
    156
    I can't comment on returning a function as the WndProc() function seems to do, but when I use WinMain(), I return an integer, which is perfectly normal as the function type is int....
    MSDN <- Programmers Haven!

  3. #3
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    no, they dont' return two types., that is illegal.

    they're calling conventions. search MSDN for more information. i found it in about 2 minutes worth of googling (and i suck at googling)
    Last edited by m37h0d; 06-23-2009 at 12:49 PM.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No they have one return type. WINAPI is not a return type - it is a declaration of the calling convention. CALLBACK is another declaration of the calling convention.

    A calling convention is basically the "what goes where and who does what" agreement between the calling code and the callee (the target of the call). If you do not use the same calling convention, things go very wrong very quickly.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21