separate string and other stuff in const section

This is a discussion on separate string and other stuff in const section within the DSP forums in Other Technologies category; Hi, .const section includes string and some const data stuff. Is that possible to move string to some other memory without moving const data? Thanks...

Go Back   Application Development Forum > Other Technologies > DSP

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-05-2008, 08:46 AM
Jiandong Xu
Guest
 
Default separate string and other stuff in const section

Hi,

.const section includes string and some const data stuff. Is that possible
to move string to some other memory without moving const data? Thanks


Reply With Quote
  #2  
Old 09-05-2008, 09:10 AM
John
Guest
 
Default Re: separate string and other stuff in const section

On Sep 5, 8:46*am, "Jiandong Xu" <jiandong...@nsn.com> wrote:
> Hi,
>
> .const section includes string and some const data stuff. Is that possible
> to move string to some other memory without moving const data? Thanks


There is a missing piece of information here. Can you provide it?

John
Reply With Quote
  #3  
Old 09-05-2008, 10:27 AM
John Barrett
Guest
 
Default Re: separate string and other stuff in const section

Depending on the platform.. look for #pragma or similar compiler directives,
or provide more info about the development environment and target device.
When you search for the directives, keep in mind they may not be #commands..
one compiler I worked with long ago used specifically formatted comments to
control memory layout.

"John" <sampson164@gmail.com> wrote in message
news:6187cd3f-aeb8-4bbb-b5d6-c52b4b14530b@k13g2000hse.googlegroups.com...
On Sep 5, 8:46 am, "Jiandong Xu" <jiandong...@nsn.com> wrote:
> Hi,
>
> .const section includes string and some const data stuff. Is that possible
> to move string to some other memory without moving const data? Thanks


There is a missing piece of information here. Can you provide it?

John


Reply With Quote
  #4  
Old 09-05-2008, 02:42 PM
Nils
Guest
 
Default Re: separate string and other stuff in const section

Jiandong Xu wrote:
> Hi,
>
> .const section includes string and some const data stuff. Is that possible
> to move string to some other memory without moving const data? Thanks
>
>


Hi,
Yes.

Nils
Reply With Quote
  #5  
Old 09-05-2008, 09:32 PM
Vladimir Vassilevsky
Guest
 
Default Re: separate string and other stuff in const section



Jiandong Xu wrote:

> Hi,
>
> const section includes string and some const data stuff. Is that possible
> to move string to some other memory without moving const data? Thanks


In the most of the embedded compilers, you can explicitly define memory
section for every particular object. Many compilers have an option if
the strings are kept in RAM (as required by C standard) or stored in the
constant memory.


Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com





Reply With Quote
  #6  
Old 09-05-2008, 10:21 PM
Jack Klein
Guest
 
Default Re: separate string and other stuff in const section

On Fri, 05 Sep 2008 20:32:53 -0500, Vladimir Vassilevsky
<antispam_bogus@hotmail.com> wrote in comp.dsp:

>
>
> Jiandong Xu wrote:
>
> > Hi,
> >
> > const section includes string and some const data stuff. Is that possible
> > to move string to some other memory without moving const data? Thanks

>
> In the most of the embedded compilers, you can explicitly define memory
> section for every particular object. Many compilers have an option if
> the strings are kept in RAM (as required by C standard) or stored in the
> constant memory.


There is nothing in the C standard that requires all strings to be
stored in RAM. Given:

char *s1 = "string one";
char s2[] = "string two";
const char s3[] = "string three";

....only the character array s2 needs to be stored in RAM. The string
literal and the array of const chars can be stored in read-only memory
or in RAM.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Reply With Quote
  #7  
Old 09-06-2008, 01:55 AM
glen herrmannsfeldt
Guest
 
Default Re: separate string and other stuff in const section

Jack Klein wrote:
(snip)

> There is nothing in the C standard that requires all strings to be
> stored in RAM.


In K&R C, string constants were writable. That ability
was removed in ANSI C, but many compilers support it for
back compatibility.

> Given:


> char *s1 = "string one";
> char s2[] = "string two";
> const char s3[] = "string three";


> ...only the character array s2 needs to be stored in RAM. The string
> literal and the array of const chars can be stored in read-only memory
> or in RAM.


-- glen

Reply With Quote
  #8  
Old 09-08-2008, 01:42 AM
Jiandong Xu
Guest
 
Default Re: separate string and other stuff in const section

Thanks for your reply.

sure, it is TI compiler: TI C6000 Code Generation Tools: v6.0.5, from Code
Composer Studio v3.3

I do remember some compilers can put string section somewhere. But I can't
find any information from TI manual.

>Depending on the platform.. look for #pragma or similar compiler

directives,
>or provide more info about the development environment and target device.


>When you search for the directives, keep in mind they may not be

#commands..
>one compiler I worked with long ago used specifically formatted comments

to
>control memory layout.
>
>"John" <sampson164@gmail.com> wrote in message
>news:6187cd3f-aeb8-4bbb-b5d6-c52b4b14530b@k13g2000hse.googlegroups.com...
>On Sep 5, 8:46 am, "Jiandong Xu" <jiandong...@nsn.com> wrote:
>> Hi,
>>
>> .const section includes string and some const data stuff. Is that

possible
>> to move string to some other memory without moving const data? Thanks

>
>There is a missing piece of information here. Can you provide it?
>
>John
>
>
>

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:15 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.