const vs. #define

Mateusz Loskot mateusz at LOSKOT.NET
Thu Oct 19 12:26:36 EDT 2006


Ed McNierney wrote:
> I can't imagine it makes any detectable difference in the generated 
> code.

If C compiler supports C99 and const qualifier is well supported,
using const than #define should be preferable.
const is language implementation feature, but #define is a preprocessor
feature.
const as a langauge feature, is "detectable" by compiler, so it's
faster to find bugs when misused.
I think it's always worth to use compiler for bugs detection
wherever it's possible.

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the mapserver-dev mailing list