Topic : const arrays and scanf

Forum : ST7/STM8

Original Post
Post Information Post
October 29, 2010 - 6:21pm
Guest

The compiler fails to recognize const array parameters passed to const actual parameters of functions, e.g.:

void func(const int actual[])
{
//Function body
}

const int formal[1] = {0};

main()
{
func(formal);
/* RCSTM8 Compiler signals an error here:
ERROR C204 IN LINE 10 OF C:\Project\file.c : pointer: const to non-const assignment
*/
}

I must cast (int*)formal everywhere to avoid the fake error. Very ugly!

scanf function still not implemented on STM8 libraries! What a missing for a professional product!

Regards.

Giorgio

Replies
Post Information Post
+1
0
-1
November 2, 2010 - 8:41am
Raisonance Support Team

Hi Giorgio,

We rpoperly reproduced the problem in our Labs. It looks like the compiler does not keep the "const" qualifier in "const int actual[]".

We will investigate and fix this, however it will not be fixed in the next release of the RKit-STM8, which is due this week.

The scanf function is not available for STM8, but we will add it in a future release. Not many people use it as it has a huge footprint, it is usually more efficient to use a hand-made strtoint than to use scanf. If you want a nice string-to-int conversion routine you can get it from the CircleOS sources at http://www.stm32circle.com.

Regards,
Bruno