<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 13, 2016 at 11:53 AM, Jose Fonseca <span dir="ltr"><<a href="mailto:jfonseca@vmware.com" target="_blank">jfonseca@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 13/04/16 19:35, Jason Ekstrand wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
<br>
On Wed, Apr 13, 2016 at 10:19 AM, Emil Velikov <<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a><br></span>
<mailto:<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>>> wrote:<br>
<br>
    From: Jose Fonseca <<a href="mailto:jfonseca@vmware.com" target="_blank">jfonseca@vmware.com</a> <mailto:<a href="mailto:jfonseca@vmware.com" target="_blank">jfonseca@vmware.com</a>>><span class=""><br>
<br>
    Not supported by MSVC, and completely unnecessary -- inline functions<br>
    work just as well.<br>
<br>
    NIR_SRC_INIT/NIR_DEST_INIT could and probably should be replaced by the<br>
    inline functions.<br>
<br></span>
    Cc: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a> <mailto:<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>>><div><div class="h5"><br>
<br>
    ---<br>
<br>
    Jason, I believe you (used to) have an alternative in the vulkan branch.<br>
    This approach looks more reasonable imho, although I don't feel strongly<br>
    either way.<br>
<br>
    -Emil<br>
    ---<br>
      src/compiler/nir/nir.h | 18 ++++++++++++++++--<br>
      1 file changed, 16 insertions(+), 2 deletions(-)<br>
<br>
    diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
    index ebac750..0adadc2 100644<br>
    --- a/src/compiler/nir/nir.h<br>
    +++ b/src/compiler/nir/nir.h<br>
    @@ -503,7 +503,14 @@ typedef struct nir_src {<br>
         bool is_ssa;<br>
      } nir_src;<br>
<br>
    -#define NIR_SRC_INIT (nir_src) { { NULL } }<br>
    +static inline nir_src<br>
    +nir_src_init(void)<br>
    +{<br>
    +   nir_src src = { { NULL } };<br>
    +   return src;<br>
    +}<br>
    +<br>
    +#define NIR_SRC_INIT nir_src_init()<br>
<br>
<br>
Is this a problem in C or only in C++?<br>
</div></div></blockquote>
<br>
IIRC, the problem was with C.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If it's only a problem in C++,<br>
another option (and I've written this patch before) is to do<br>
<br>
#ifdef _cplusplus<br>
#define NIR_SRC_INIT nir_src()<br>
#else<br>
#define NIR_SRC_INIT { { NULL } }<br>
#endif<br>
<br>
and the same for NIR_ALU_SRC_INIT, NIR_DST_INIT, etc.<br>
</blockquote>
<br></span>
But is there any thing to be gained by using { { NULL } } as opposed to the inline?  Is the generated code better, or error messages cleaner or something like that?<br></blockquote><div><br></div><div>I don't know.  What I'd really prefer is <br><br></div><div>#define NIR_SRC_INIT ((nir_src) { { NULL } })<br><br></div><div>which is type-safe but doesn't work in C++.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Generally speaking inlines tend to have much better characteristics that macros (e.g, in this case, type safety).<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">I guess I'm ok with the inline.  I think it's ugly and nasty but the compiler should get rid of it just fine.<br></div></div>