|
|
View previous topic :: View next topic |
Author |
Message |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
This can’t be a feature. I’m somewhat outraged. |
Posted: Sat Jul 18, 2009 9:00 pm |
|
|
This can’t be a feature. This is either a bug or lack of feature.
I have a function with the following arguments:
Code: | void i2c_write_block(
int8 iI2CAddr, // [in] I2C address of the remote chip where the register resides
int16 iRegAddr, // [in] address of the register on the remote chip
int8 iBytes, // [in] number of bytes to write to the external chip
int8* pVals) // [in] pointer to the buffer to write the data from |
Due to a coding error, I write a call to a function, which has the last 2 arguments swapped.
Code: | int8 aiInBuff[i_BUFF_SIZE]; // buffer to receive the data from the EEPROM into
i2c_read_block(iI2CAddr, iCurrAddr, &aiInBuff[0], i_BUFF_SIZE); |
Compiler should generate a compile-time error. Compiler didn’t catch it. I’m outraged. PICs with a CCS compiler is okay for a start, but soon it will be LPC2000 with IAR compiler. As Gorby used once said about perestroika: “The process is underway” **.
** M.S. Gorbachev “Процесс пошел!” _________________ Read the label, before opening a can of worms. |
|
|
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
may I be philosophical for a moment ? |
Posted: Sun Jul 19, 2009 1:22 am |
|
|
I am not going to comment on the compiler not warning you.
I would merely say that you must be a very young man (I am 60).
You may have a reason to be disappointed, but keep your outrage for real problems in life, or you wont make it through to the other side.
Mike |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Jul 19, 2009 2:12 am |
|
|
You are complaining about lack of type checking in CCS C?
According to most C-standards, type checking is optional, so missing type checking surely isn't a bug. I agree, that type checking can help to avoid some simple coding errors.
When using compilers that involve extensive type checking, e.g. embedded Visual C, I found, that the most nasty coding errors are not detected by type checking anyway...
I don't remember a particular coding error in CCS C work, that would have been avoided by more type checking, but there may be some. In my opinion, it's a less important in CCS C features. |
|
|
Ttelmah Guest
|
|
Posted: Sun Jul 19, 2009 8:43 am |
|
|
The key is to understand that C itself, is not a 'strong typed' language. It has built in, automatic casting of values to the required type, if possible, as they are passed to/from functions. This makes it perefectly possible, and acceptable, to pass an integer, to a function expecting a pointer, and the integer, will be used as a pointer when passed, without complaint. This behaviour, is potentially dangerous, _but is part of C_. I can do this, on an old Unix C, and it works fine...
It is a powerful ability, but also potentially dangerous.
This behaviour was changed, with latter variants, with ANSI C increasing the checking, and things like C++, making casts obligatory, to reduce the risks.
If you want stronger checking, then use a separate syntax checker. Many people here do exactly this, passing the code through third party checkers, before doing the final compilation.
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Jul 19, 2009 8:51 am |
|
|
I do understand it is very annoying to waste time searching for a bug that the compiler could have easily warned you for. But, it is a missing feature, not a bug.
At my work we are using the same code base to compile for three different OS-es and it is surprising to see how each compiler warns against different bad coding practices. The IAR compiler might be better than CCS, but be assured you will find missing features here as well.
Send an email to CCS to ask for this missing feature to be added. Only features asked for by customers will be implemented. If you don't think it worth to send an email, than it is not worth complaining either. |
|
|
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
OK, leave the guy alone now |
Posted: Sun Jul 19, 2009 9:08 am |
|
|
OK, we have flamed him enough.
Finally, the other important point is the cost.
The CCS compiler is $250 or so.
The cheapest IAR for ARM is the one below, the most expensive being £3,000+
IAR Baseline Embedded Workbench for ARM - 256KB Code Limited
As for Embedded Workbench for ARM except MISRA C Checker, Design tools and Printed User Guides are not included. Support not included - support is charged at £300 for 12 months.
Price: £1,580.00 / €1,738.00
We accept the limitations and quirks with CCS for the low cost compiler, and this brilliant forum.
Mike |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Sun Jul 19, 2009 6:13 pm |
|
|
FvM wrote: | You are complaining about lack of type checking in CCS C?
According to most C-standards, type checking is optional, so missing type checking surely isn't a bug. I agree, that type checking can help to avoid some simple coding errors. |
You need to take this problem up with Kernighan and Richie. This is the reason Nicklaus Wirth designed Pascal. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
better yet no type required |
Posted: Mon Jul 20, 2009 7:56 am |
|
|
back when i was using training wheels - i recall True Basic - which has
only two types to check - string or numeric - where ANY numeric is internally converted to whatever you need for a given calculation - integer to IEEE float - signed or unsigned - makes no never mind - and the first use of a data item initializes it.
strings were limited to 64Kb each - with no zero tag - - instead using an
unsigned int16 preceding the string data and if you are a primitive user you did not have to know about that either since the only access to the headers was through 808x ASM anyway.
i still use it when i want to prototype a hi level math intensive routine in a hurry - because it is SIMPLE ,accurate and foolproof - even for a 60++ year old.
of course , that required a heck of a lot of overhead such that hello world , when compiled - carried 100k of executive baggage.
too bad there is no PIC version
|
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
Re: OK, leave the guy alone now |
Posted: Wed Jul 22, 2009 9:01 pm |
|
|
MikeW wrote: |
We accept the limitations and quirks with CCS for the low cost compiler, and this brilliant forum.
|
Ya know, it's interesting that I did a project in C18 from Microchip... and when I converted it to CCS because of what a pain some of the C18 quirks gave me, I got back about 30% of my program space and was able to implement all my features without changing the micro to a bigger device.
I've looked at the ASM code CCS generates and in a lot of cases, it's not too bad. I've done my share of hand-tuning ASM in CCS for speed -- but not too often. They've got a lot of nice optimization in there...
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|
|
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
|