At 11:08 PM 10/17/05 +0000, Guillermo Prandi wrote:
>Hi! Has anybody found this? I'm using gcc 4.01 (latest WinARM) and I'm
>compiling for LPC2138 (ARM7). If I use this kind of stuff, constants
>don't get to the HEX file:
It sounds like a problem with your startup code.
>char *c = "Hello";
This string, for instance needs to be copied to RAM since your declaration
indicates it's modifiable.
>or
>
>my_func("Hello");
As will this if my_func is prototyped as void my_func (char *)
I think that's the case.
>However, if I use a built-in function like printf or puts, they do!:
>
>printf("Hello");
This however can point to the string in flash since printf expects a const
string.
The prototype is something like
int printf( const char *, ...);
Question: Does the problem disappear if you declare the first case as
const char *c = "Hello";
and prototype the function in the second as
void my_func( const char *);
>This only happens with -On, where n != 0.
I'd be really confident that was the problem, except I don't see how this
final statement fits in.
Still the const/non-const nature of the two cases cries out as being
critical. Maybe you are writing over the strings in RAM?
Robert
" 'Freedom' has no meaning of itself. There are always restrictions, be
they legal, genetic, or physical. If you don't believe me, try to chew a
radio signal. " -- Kelvin Throop, III
http://www.aeolusdevelopment.com/Message
Re: [lpc2000] Problems with sting constants and gcc -On
2005-10-17 by Robert Adsett
Attachments
- No local attachments were found for this message.