On 17/08/16 00:42, Carsten Haitzler (The Rasterman) wrote:
> On Tue, 16 Aug 2016 20:16:04 -0300 Iván Briano <sach...@deadferret.net> said:
>
>> On Tue, 16 Aug 2016 21:22:32 +0900, Carsten Haitzler wrote:
>>> On Tue, 16 Aug 2016 11:44:03 +0000 Mike Blumenkrantz
>>> <michael.blumenkra...@gmail.com> said:
>>>
>>> no worries. it's the same for SSH_ASKPASS too - you still get the normal tty
>>> password req is there is a tty. if there is not both sudo and ssh can fail
>>> (unless you have a no-password ssh key or sudo is configured for nopasswd
>>> for your user). so these work as normal in the no password cases. in the
>>> cases you do need a password both will fail completely. this adds this
>>> little utility so these don't hail anymore if they are in .desktop file or
>>> other command/app/script you launch from within e... :) overall this makes
>>> e more functional... thus i don't see a problem in ALWAYS setting the env
>>> var. if someone dislikes this they can override the env vars or unset them
>>> in scripts. and even in e's environment var settings since e_env_init is
>>> called after these env vars are set... :) but for the vast majority of
>>> people .. they don't need this or likely want it.. and things went from not
>>> working to working out of the box with no effort on their part. :)
>>>
>>> some small things to improve in e here. i'll poke around some other small
>>> things here and there as i get the time. :)
>>
>> Now explain the do { } while(0). If all you wanted to do was indent the
>> blocks hierarchically, why not just { }? I had to pay to download all
>> those extra characters.
>
> technically  {} is not legal. it works. thats why so many macros in our public
> headers have do { } while (0); because a { } may not work.
>
> http://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for
>
> it's a habit i've grown from making sure macros work. yes - using it to indent
> the code so you can clearly see child/parent relationships in widgets. i'm
> trying this out as a way to make things look more readable when going over gui
> layout code.
>

A slight correction: as far as I know, {} is perfectly legal (I used it 
all the time everywhere). However, as you mentioned, you should not use 
it in macros, and should use do-while instead. The reason for that is to 
force a semicolon at the end of macros.

For macros FOO1 and 2:
#define FOO1(x) { ... }
#define FOO2(x) do { ... } while (0)


FOO1(1) // will work
FOO1(1); // will possibly generate a warning for extraneous semicolon

FOO2(1) // will not compile
FOO2(1); // will work as expected.

I use {} and I think it's better than putting do-while in code, but I 
think if you insist on using a loop construct for indention, I'd do "if 
(1)" or something like that.

--
Tom.

------------------------------------------------------------------------------
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to