Does default function will return any value?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikerich135
    New Member
    • May 2007
    • 2

    Does default function will return any value?

    Is it possible that any function without return type and returning value will return any value. If so, How?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by mikerich135
    Is it possible that any function without return type and returning value will return any value. If so, How?
    Nope, a void function doesn't return anything at all; never. And none of the
    callers of a void function expect it anything to return.

    kind regards,

    Jos

    Comment

    • svlsr2000
      Recognized Expert New Member
      • Feb 2007
      • 181

      #3
      It depends on the compiler. The compiler in which i am working, uses register R1, to return values to Caller.

      Usually when we define some functions in assembly, we write the return values in R1 if its 16 bit and use other consecutive registers if we have to return something higher then 16 bit.

      Similiarly i think we can write something in register R1 or corresponding register in your compiler to check whether the function have returned something or not.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by svlsr2000
        It depends on the compiler. The compiler in which i am working, uses register R1, to return values to Caller.

        Usually when we define some functions in assembly, we write the return values in R1 if its 16 bit and use other consecutive registers if we have to return something higher then 16 bit.

        Similiarly i think we can write something in register R1 or corresponding register in your compiler to check whether the function have returned something or not.
        Sure, but then the calling function must be able to inspect R1. You can't just
        use C or C++ for this because this:
        Code:
        void foo() /* store something in R1 */}
        void bar() { T x= foo(); }
        ... always fails for any type T, even if T is type 'void'.

        kind regards,

        Jos

        Comment

        Working...