Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail: variables with a same name, ifdef preprocessor branching #27

Open
0b5vr opened this issue Mar 9, 2021 · 2 comments
Open

fail: variables with a same name, ifdef preprocessor branching #27

0b5vr opened this issue Mar 9, 2021 · 2 comments

Comments

@0b5vr
Copy link

0b5vr commented Mar 9, 2021

Related: #28

Input

void main() {
#ifdef CONDITION
  vec3 col = vec3( 1.0 );
#else
  vec3 col = vec3( 0.0 );
#endif

  gl_FragColor = vec4( col, 1.0 );
}

Actual

void main(){
#ifdef CONDITION
vec3 C=vec3(1.);
#else
vec3 r=vec3(0.);
#endif
gl_FragColor=vec4(r,1.);}

Expected

void main(){
#ifdef CONDITION
vec3 C=vec3(1.);
#else
vec3 C=vec3(0.);
#endif
gl_FragColor=vec4(C,1.);}
@laurentlb
Copy link
Owner

laurentlb commented Mar 10, 2021

Here, the workaround can be to declare the variable before the macro:

void main() {
  vec3 col;
#ifdef CONDITION
  col = vec3( 1.0 );
#else
  col = vec3( 0.0 );
#endif
  gl_FragColor = vec4( col, 1.0 );
}

@0b5vr
Copy link
Author

0b5vr commented Mar 16, 2021

yes I'm using that workaround right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants