Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Bug Reports / [DBPro U7.7 RC6] Declaring constants to constants don't work right

Author
Message
Admiral MH
13
Years of Service
User Offline
Joined: 10th Feb 2011
Location: TX, USA
Posted: 23rd Mar 2011 21:42
Here is the following code.



So adding constants to earlier declared constants don't work.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Mar 2011 18:25 Edited at: 24th Mar 2011 18:25
I don't think it's meant to - not that way anyway. I think your code is working correctly - I suspect your understanding of it is wrong.

The compiler first removes all the constant declarations so that your code then looks like this:



It then replaces all the constant names with the text specified in your constant declarations. Your code then looks like this:



The compiler then compiles your code and sees two variables C_One and C_Two which are initialised to zero.

Constants are just a convenient way of replacing commonly occurring bits of code with something more meaningful to the programmer - and the compiler simply reinstates those bits of code for you before it does the main compile.
Admiral MH
13
Years of Service
User Offline
Joined: 10th Feb 2011
Location: TX, USA
Posted: 24th Mar 2011 20:30 Edited at: 24th Mar 2011 20:31
Ah that makes sense. It helps out to know how constants are compiled. Thank for your help.

Login to post a reply

Server time is: 2024-04-25 10:06:36
Your offset time is: 2024-04-25 10:06:36