Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Re: gnuarm question

2006-02-12 by Clyde Stubbs

On Sun, Feb 12, 2006 at 05:11:07PM -0500, Sean wrote:
> 
> char * const test5p   = "test 5 pointer"; // .rodata

> test5p[0] = 'o'; // .rodata; ok   ****

> Except for test5p -- it's mapped to .rodata yet the compiler allows me to 
> try to change it, while it won't let me change test5b??

the pointer variable test5p is mapped to .rodata, but what it points to
is not. Your assignment is not changing test5p, just the contents of
the memory that it points to, which is a string literal, with a type
of "char *", NOT "const char *".

In the case of:

> char   const test5b[] = "test 5 bracket"

there is no pointer, just an array with an initializer.

Clyde

-- 
Clyde Stubbs                     |            HI-TECH Software
Email: clyde@...          |          Phone            Fax
WWW:   http://www.htsoft.com/    | USA: (408) 490 2885  (408) 490 2885
PGP:   finger clyde@...   | AUS: +61 7 3722 7777 +61 7 3722 7778
---------------------------------------------------------------------------
HI-TECH C: compiling the real world.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.