Re: [Mesa-dev] void operation in glsl
On 08/26/2013 02:42 PM, Matt Turner wrote: On Sun, Aug 25, 2013 at 10:07 PM, Liu Xin wrote: HI, list, i don't understand why glsl source have so many 'cast to void' operations, like this. ir_rvalue * ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { (void) instructions; (void) state; return NULL; } i think it's totally void operation, do you guy just make gcc compiler happy? Yes, the purpose is only to avoid unused variable warnings emitted by the compiler. yes it is. now i understood. clean code! --lx ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] void operation in glsl
On Sun, Aug 25, 2013 at 10:07 PM, Liu Xin wrote: > HI, list, > > i don't understand why glsl source have so many 'cast to void' operations, > like this. > > ir_rvalue * > ast_node::hir(exec_list *instructions, > struct _mesa_glsl_parse_state *state) > { >(void) instructions; >(void) state; > >return NULL; > } > > i think it's totally void operation, do you guy just make gcc compiler > happy? Yes, the purpose is only to avoid unused variable warnings emitted by the compiler. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] void operation in glsl
It's just a simple, portable way to make the `unused parameter` warning shut up, when you're deliberately ignoring your parameters. There are other ways [__attribute__(( unused )), etc] but they cease to be simple or portable fairly quickly. -- Chris On Mon, Aug 26, 2013 at 5:07 PM, Liu Xin wrote: > HI, list, > > i don't understand why glsl source have so many 'cast to void' operations, > like this. > > ir_rvalue * > ast_node::hir(exec_list *instructions, > struct _mesa_glsl_parse_state *state) > { >(void) instructions; >(void) state; > >return NULL; > } > > i think it's totally void operation, do you guy just make gcc compiler > happy? > > thanks, > --lx > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev