??? 09/24/08 09:47 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#158573 - const is expected to catch non-const assigns Responding to: ???'s previous message |
The compiler is expected to produce that error when it see a const pointer assigned to (or sent as function argument) a non-const pointer.
That is the main purpose of the const keyword. Without this, there would be no use of the keyword. This makes sure that a program doesn't try to use this new non-const pointer to modify the data. When you get an error, do post the relevant source code too. One little problem with const - a lot of older RTL does not specify correct function prototypes for a number of standard string functions. For example: if strlen is defined as strlen(char* p) instead of strlen(const char* p) then you will get a problem when the const keyword is used. Everyone knows that strlen does not modify the input string, but the compiler don't care about what the manual says about strlen. It can only base its actions on the actual function prototype. |
Topic | Author | Date |
Location of Pointers in XDATA | 01/01/70 00:00 | |
What does datasheet says? | 01/01/70 00:00 | |
RC-51 ref manual, pg 51 | 01/01/70 00:00 | |
ahh so easy when you read the instructions | 01/01/70 00:00 | |
xdata? | 01/01/70 00:00 | |
too? | 01/01/70 00:00 | |
Well yes actually - now that you mention it | 01/01/70 00:00 | |
what do you really want? | 01/01/70 00:00 | |
You are correct you supplied the answer as asked | 01/01/70 00:00 | |
wronk 'keyword' | 01/01/70 00:00 | |
const + code | 01/01/70 00:00 | |
the compiler is smart enough to ... | 01/01/70 00:00 | |
Compiler-specific? | 01/01/70 00:00 | |
It didn't actually compile with CONST | 01/01/70 00:00 | |
const is expected to catch non-const assigns![]() | 01/01/70 00:00 |