a trick in C

xiaoxiao2021-03-06  19

In CII CHAP 04, the macro definition for Return is:

#define return switch (Exception_stack = exception_stack-> prev, 0) Default: Return

Put in the following code:

Try

/ * Do Something * /

IF (failed)

Return 1;

ExceTpt (allocation_failed)

/ * Handle Allocation Fail * /

END_TRY

After the start is: (I don't consider the macro definition of TRY)

Try

/ * ... * /

IF (failed)

Switch (exception_stack = exception_stack-> prev, 0)

DEFAULT:

Return 1;

Except (allocation_failed)

...

END_TRY

It can be seen that this macro's only purpose is to execute an Exception_Stack = Exception_stack-> prev statement before returnit 1.

After careful consideration, you can find that other structures in the C language cannot meet this condition. If you use #define returnix (exception_stack = exception_stack-> prev, 1) Return

In IF (...) returnit 1; ELSE ... statement, the ELSE is erroneous.

The only function I think is: #define return (Exception_stack = exception_stack-> prev, 0) (Void) 0): Return

转载请注明原文地址:https://www.9cbs.com/read-44499.html

New Post(0)