call return inside GCC compound statement expressions -
Can I safely use returns within the GCC compound statement expressions?
defines macros for example I
#define CHECK_FUNC_RESULT (func) \ ({\ int result = func (); \ if (! Result) return; \ Result; \}) and use it somewhere else in the code like this:
int function1 () {returns (if some_condition) 0 ; ... return 1; } Void function2 () {if (CHECK_FUNC_RESULT (function1)} {... to do something}} What I really == on function2 (some_condition without any undefined behavior) Can I expect to return from?
This should work, but if your () action If the function1 1 returns is your example: never) it looks like a dangerous construction, because nobody else will ever be executed.
Comments
Post a Comment