Is it possible that any function without return type and returning value will return any value. If so, How?
Does default function will return any value?
Collapse
X
-
Tags: None
-
Nope, a void function doesn't return anything at all; never. And none of theOriginally posted by mikerich135Is it possible that any function without return type and returning value will return any value. If so, How?
callers of a void function expect it anything to return.
kind regards,
Jos -
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
-
Sure, but then the calling function must be able to inspect R1. You can't justOriginally posted by svlsr2000It 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.
use C or C++ for this because this:... always fails for any type T, even if T is type 'void'.Code:void foo() /* store something in R1 */} void bar() { T x= foo(); }
kind regards,
JosComment
Comment