10
\$\begingroup\$

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.

\$\endgroup\$
3
  • 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, 2015 at 17:54
  • \$\begingroup\$ @Samurai8 thank you! Should I delete this question? \$\endgroup\$
    – Lolums
    Sep 8, 2015 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, 2015 at 15:14

1 Answer 1

10
\$\begingroup\$

#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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .