Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   how is const better compared to #define (http://www.go4expert.com/forums/const-compared-define-t21664/)

micsom 5Apr2010 13:40

how is const better compared to #define
 
Its said that using const is better compared to #define...because const identifier uses compiler symbol table..

can some1 please explain why? and How?...

Thanks

xpi0t0s 6Apr2010 13:01

Re: how is const better compared to #define
 
Lots of answers to and discussions about this online. http://lmgtfy.com/?q=compare+const+define
Why do you need to start yet another thread about it?

micsom 6Apr2010 13:10

Re: how is const better compared to #define
 
thanks for the reply..i am actually interested in how symbol table comes into the picture for const and #define...

i was googling for it when i came across it..but i didn't find any satisfactory answers.

:)

xpi0t0s 6Apr2010 13:11

Re: how is const better compared to #define
 
const defines a variable which goes into the compiler's symbol table with all other variables. #define is just a lexicographical thing sorted out by the parser; the compiler never sees #defines.


All times are GMT +5.5. The time now is 01:49.