 |
 |
| View previous topic :: View next topic |
| Author |
Message |
jeremiah
Joined: 20 Jul 2010 Posts: 1411
|
|
Posted: Fri Dec 04, 2015 11:40 am |
|
|
One thing to keep in mind with CCS is even if you specify ANSI or CONST=READ_ONLY, it still won't fully treat const correctly. While it will catch a local variable being reassigned with an error, it won't catch function parameters. For example:
| Code: |
void func(const char *str){
str[0] = 'a';
}
|
It happily compiles in CCS (incorrectly) but ANSI compliant compilers will flag that with an error. For example, GCC returns
| Code: |
main.c: In function 'func':
main.c:6:4: error: assignment of read-only location '*str'
|
Visual Studio similarly flags it as an error, per ANSI requirements. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20061
|
|
Posted: Fri Dec 04, 2015 11:51 am |
|
|
This ties to a general thing in CCS, that the actual syntax checking is less than perfect.
It'll often miss things like this.
When things are wrong, it'll quite commonly flag the actual error dozens of lines after it actually occurs.
It has improved, but in the earlier compilers you will find a lot of posters (myself very much included), suggesting that you use a better tester, to actually check the code before compiling. Packages like lint... |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|