CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

typedef void (* ble_cmd_handler) (const void *);
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jeremiah



Joined: 20 Jul 2010
Posts: 1411

View user's profile Send private message

PostPosted: Fri Dec 04, 2015 11:40 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Dec 04, 2015 11:51 am     Reply with quote

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...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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