µTasker Forum

µTasker Forum => Luminary Micro TM LM3SXXXX => Topic started by: mhoneywill on June 08, 2010, 06:40:09 PM

Title: Getting GCC to use uMemset instead of memset
Post by: mhoneywill on June 08, 2010, 06:40:09 PM
Hi Mark,

I've come across the problem mentioned here http://www.utasker.com/forum/index.php?topic=249.msg1011#msg1011 where GCC is complaining about an undefined reference to in my case memset.

I was just wondering if it was possible to #define memset to uMemset and memcpy to uMemcpy somewhere to allow GCC to use the routines defined in uTasker, rather than looking in its own libraries

Its not a big problem but just a thought.

The line that caused my problem was

    unsigned char IIC_WrByte[18] = {0xc0, 0x20};            // {address, register, data x 16}

Cheers

Martin
Title: Re: Getting GCC to use uMemset instead of memset
Post by: mark on June 08, 2010, 07:01:40 PM
Hi Martin

Since the compiler is using memcpy() to initialise an array when a routine is called you could change uMemcpy() to memcpy() - or set a define somewhere to rename it.
The compiler is assuming that this routine is supplied by a standard library but the linker will or course accept any library supplying it.

However I have tended to avoid initialisation of this form in preference to:

unsigned char IIC_WrByte[18]; // = {0xc0, 0x20};            // {address, register, data x 16}
IIC_WrByte[0] = 0xc0;
IIC_WrByte[1] = 0x20;


Which you will see at various location to avoid the linker error when GCC is used.

Regards

Mark
Title: Re: Getting GCC to use uMemset instead of memset
Post by: mhoneywill on June 08, 2010, 10:33:14 PM
Thanks Mark,

Sorry I should have been clearer, what you have suggested is what I'm doing. I was just wondering where GCC was trying to pick up memset and memcpy from.

Thinking about it obviously a #define would not work but a re-definition of memset and memcpy might, just was thinking defining constant arrays might be cleaner than manually filling them.

Cheers

Martin