Originally Posted By: MasterQ32
following this both examples make no sense
you are returning no information so why using return foo(); ?

He doesn't actually want to return anything, he just wants his macro to work with void as well without having an extra macro for void functions. Geez, am I the only one actually reading more than the thread title?


Anyways, what does the C standard say to this? On page 47, section 6.3.2.2 you have the following statement about void:
Quote:

The (nonexistent) value of a void expression (an expression that has type void) shall not be used in any way, and implicit or explicit conversions (except to void) shall not be applied to such an expression. If an expression of any other type is evaluated as a void expression, its value or designator is discarded. (A void expression is evaluated for its side effects.)

(emphasis by me)

So, if you cast something to void, the result of the cast will indeed be discarded, which is quite easy to test. The following run through Clang will generate no errors, and Krials GCC output back this up as well:
Code:
int test1()
{
	printf("Hello World");
	return 24;
}
void test2()
{
	return (void)test1();
}


("Hello World" will be printed to stdout, confirming that the expression is indeed validated like the C standard mandates).

Now, if this doesn't work in Lite-C: Bad luck for you, it should work.

Last edited by JustSid; 11/03/12 14:32.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com