What is the difference between #define NAME VALUE and const int NAME = VALUE in GLSL 410 core?

As far as I can see, they both create a constant integer.

  • 1
    \$\begingroup\$ Since glsl is based on the syntax of c, I suspect this question on SO will answer your question. \$\endgroup\$ – Sumurai8 Sep 7 '15 at 17:54
  • \$\begingroup\$ @Samurai8 thank you! Should I delete this question? \$\endgroup\$ – Lolums Sep 8 '15 at 17:44
  • \$\begingroup\$ I think this question is on-topic, but I am not all that familiar with this particular stackexchange. If the question is on-topic, it does not matter it has already an answer on a different SE site; just self-answer this question with what you have learned. \$\endgroup\$ – Sumurai8 Sep 9 '15 at 15:14

#define NAME VALUE is a macro, where all instances of NAME are replaced with VALUE by the pre-processor.

The compiler handles constants. This ensures type safety.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.