Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/16/09 19:22
Read: times


 
#165427 - Because they are not equivalent
Responding to: ???'s previous message
'const' has the meaning dictated by the C language standard.

The other (should have been __code) is the one Keil is free to define the meaning of.

'const' is only a definition of your right to modify a variable. It does not say anything about storage. It is 100% up to the compiler vendor to decide if a 'const' keyword should make any storage difference, as long as the semantics of the code stands. That is why it is forbidden to make 'const' equivalent with the code segment - 'const' must be allowed to be used in situations where 'code' does not make sense. 'code' can't be used with auto variables. 'const' can.

'code' is only a definition of storage. That it will imply read-only access is just a local peculiarity of the 8051 anatomy. Storing data in the code segment of x86 running in real mode would not imply read-only access. Moving to x86 protected mode, the text segment would most probably be write-protected, and result in a segmentation fault.

In the end, storage and access attributes are completely separate, but for specific targets, a specific storage may imply a specific access, while the reverse is not true. It is a compiler vendor decision if a specific subset all 'const' declarations should be automatically upgraded to also imply alternative storage - it is neither implied nor required or forbidden by the standard.

List of 25 messages in thread
TopicAuthorDate
C lang. question            01/01/70 00:00      
   Confused            01/01/70 00:00      
      re:            01/01/70 00:00      
         Did you get the job?            01/01/70 00:00      
            Do you _want_ the job?            01/01/70 00:00      
               Same same            01/01/70 00:00      
                  Yes, that was exactly what I meant!            01/01/70 00:00      
            re:job            01/01/70 00:00      
            OR            01/01/70 00:00      
               I wouldn't have thought so?            01/01/70 00:00      
                  Who knows            01/01/70 00:00      
                     not really applicable            01/01/70 00:00      
                        I agree            01/01/70 00:00      
                           Still missing the point.            01/01/70 00:00      
                              using 'const' for 'code' would be very bad            01/01/70 00:00      
                              Two examples            01/01/70 00:00      
                                 Different issues            01/01/70 00:00      
                                    architectual            01/01/70 00:00      
                                       Actually irrelevant to the const keyword            01/01/70 00:00      
                                          if it is irrelevant, then why ...            01/01/70 00:00      
                                             Because they are not equivalent            01/01/70 00:00      
                                          Exactly.            01/01/70 00:00      
                                             Standard mechanisms for extensions            01/01/70 00:00      
      volatile applies to data - not functions            01/01/70 00:00      
   Delay loops in 'C' (or any other HLL)            01/01/70 00:00      

Back to Subject List