| ??? 09/13/02 15:44 Read: times |
#29140 - RE: Const in code, Luca |
luca ubiali wrote:
------------------------------- const char msg[] = "ACME Wotsit v2.03"; ... the whole string goes both in code *and* in data (meaning that it is in code and is copied in data at startup). ... All in all I think that we will just add a warning when a const declaration is found to tell the user that his variable is going to be duplicated in code and data and that he *might* want to use "code" instead of "const" to prevent this. Just to be clear, "const", in this case, has nothing to do with the string ending up in both code memory and data memory. It could have been: char msg[] = "ACME Wotsit v2.03";and you would observe the same duplication. As an initialized variable, the intializer (the string) is stored in code memory and the runtime startup copies it to data memory. All initialized variables work this way, regardless of whether they are declared "const" or not. |
| Topic | Author | Date |
| Define Vs Constant | 01/01/70 00:00 | |
| RE: Define Vs Constant | 01/01/70 00:00 | |
| RE: Define Vs Constant | 01/01/70 00:00 | |
| RE: Define Vs Constant (Andy) | 01/01/70 00:00 | |
| RE: Define Vs Constant Luca | 01/01/70 00:00 | |
| RE: Define Vs Constant (Andy) | 01/01/70 00:00 | |
| RE: Define Vs Constant (Luca | 01/01/70 00:00 | |
| RE: Const in code | 01/01/70 00:00 | |
| RE: Const in code, Andy | 01/01/70 00:00 | |
| RE: Const in code, Andy | 01/01/70 00:00 | |
| RE: Const in data, Luca | 01/01/70 00:00 | |
RE: Const in code, Luca | 01/01/70 00:00 |



