AnsweredAssumed Answered

[Bug Report] strang bug with macros

Question asked by danny02 on Jan 25, 2013
Latest reply on Jan 25, 2013 by gsellers

Hi, I wrote me a little glsl macro to initialize color constants with a hex number like 0xFF0000 for red.


so the macro looks like:

#define HexColor(x) (vec3((x>>16)&0xFF,(x>>8)&0xFF,(x)&0xFF)/255)


I run it succesfully on an Intel onboard card, but when I trie to use it with my 5770 I got these strange compile errors:

ERROR: 0:100: error(#143) Undeclared identifier undefined

ERROR: 0:100: error(#132) Syntax error: '<' parse error


when I split the macro into several lines like this:

define HexColor(x)(\\



                    (x>>8 )          &0xFF,\\


          ) / 255\\



the first error disapears.


Now the strange thing, when I use the code directly without the define, so:

const vec3 COLOR = (vec3((0xFFB86B>>16)&0xFF,(0xFFB86B>>8)&0xFF,(0xFFB86B)&0xFF) /255) ;

instead of:

const vec3 COLOR = HexColor(0x6B9FFF);


everything works fine.


I can of course create a function which works just fine, but I can't use it then for constants.


I wouldn't complain if the code wouldn't work at all, but it just don't work if used through a macro