- 1

How Manny arguments void can return

3rd Feb 2019, 12:02 PM
Patryk Kirszenstein
Patryk Kirszenstein - avatar
3 odpowiedzi
+ 4
At least 1 appearently :) #include <iostream> #ifdef __GNUC__ // Returns the argument passed to it void returnSomething( int i ) { __asm__ __volatile__( "mov %0, %%eax" : : "r"( i ) : "eax" ); } #endif int main() { #ifdef __GNUC__ returnSomething( 8 ); int i; __asm__ __volatile__( "mov %%eax, %0" : "=r"( i ) : : "eax" ); std::cout << i; // prints 8 #endif } Just in case...: void returns nothing, but that doesn't mean you can't work around it. :)
3rd Feb 2019, 12:19 PM
Dennis
Dennis - avatar
0
And what about pointer arguments?
3rd Feb 2019, 12:33 PM
Patryk Kirszenstein
Patryk Kirszenstein - avatar
0
Still 1 m8, the pointer itself may point to an array or something but only the pointer itself is returned.
3rd Feb 2019, 12:41 PM
Dennis
Dennis - avatar