RFR: (8031737) rename jni_util.h macros for checking and returning on exceptions

Ulf Zibis Ulf.Zibis at CoSoCo.de
Thu Jan 16 20:15:19 UTC 2014


Very much thanks Roger.

I still would prefer "false" over "0" to avoid misinterpretation like I did :-(

-Ulf

Am 16.01.2014 20:44, schrieb roger riggs:
> Check out the stackoverflow.com and bytes.com for explanations with examples.
> Using the pattern gives consistent results in a wide range of source contexts
> and parameter strings.  Macros are textual substitutions; the c compiler
> only sees it after all the substitutions are done.
>
> "The |do ... while| and |if ... else| are there to make it so that a semicolon after your macro
> always means the same thing. Let's say you had something like your second macro."
>
> http://stackoverflow.com/questions/154136/do-while-and-if-else-statements-in-c-c-macros
>
> The whole idea of using 'do/while' version is to make a macro which will
> expand into a regular statement, not into a compound statement. This is
> done in order to make the use of function-style macros uniform with the
> use of ordinary functions in all contexts.
>
> [2] http://bytes.com/topic/c/answers/219859-do-while-0-macro-substitutions
>
>
> On 1/16/2014 1:57 PM, Ulf Zibis wrote:
>> Hi,
>>
>> thanks, I thought this is an endless loop until the inner condition is fulfilled, not really
>> noting, that 0==false (one more reason to use true/false instead 1/0, IMHO).
>>
>> Can you explain the trick, why you use a one-time-loop instead of a single statement?
>>
>> -Ulf
>>
>>
>> Am 16.01.2014 19:13, schrieb roger riggs:
>>> Hi,
>>>
>>> The current do {...} while(0) is the established idiom in the jdk.
>>>
>>> It does not have the potential problem of unintentionally allowing
>>> an infinite loop if the body contains a 'continue'.
>>>
>>> Roger
>>>
>>> On 1/16/2014 12:56 PM, Ulf Zibis wrote:
>>>> Am 16.01.2014 17:26, schrieb roger riggs:
>>>>> Please review:
>>>>>
>>>>> webrev:
>>>>> http://cr.openjdk.java.net/~rriggs/webrev-jnu-check-rename-8031737/
>>>>
>>>> I more would like a "while (true)" loop, rather than a "do" loop.
>>>>
>>>> -Ulf
>>>>
>>>
>>>
>>
>
>




More information about the core-libs-dev mailing list