This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with the string


kanishk rastogi writes:
 > On 11/24/06, Andrew Haley <aph@redhat.com> wrote:
 > > kanishk rastogi writes:
 > >  > On 11/24/06, Andrew Haley <aph@redhat.com> wrote:
 > >  > > kanishk rastogi writes:
 > >  > >  > On 11/24/06, Andrew Haley <aph@redhat.com> wrote:
 > >  > >  > > kanishk rastogi writes:
 > >  > >  > >  > if i call a func like:
 > >  > >  > >  >
 > >  > >  > >  > func("kanishk");
 > >  > >  > >  > the string "kanishk" will be defined in readonly segment or in read -
 > >  > >  > >  > write segment ?
 > >  > >  > >  > if they will be in read-only segment i dont want that....
 > >  > >  > >  > how can this be done
 > >  > >  > >
 > >  > >  > > Dammit, how many times do I have to repeat this?
 > >  > >  > >
 > >  > >  > > You just gotta declare them right.  Like this:
 > >  > >  > >
 > >  > >  > > char s[] = "kanishk";
 > >  > >  > > func(s);
 > >  > >
 > >  > >  > thanks for the advice andrew
 > >  > >  > and sorry for the annoyance
 > >  > >  > but the fact is I cant change the code because its more than 8000
 > >  > >  > lines so i am asking for a feature in gcc which i would have missed
 > >  > >
 > >  > > Your code is wrong.  "How do I get gcc to compile this code with these
 > >  > > bugs?" is not a sensible question.  Fix the bugs!
 > >
 > >  > sorry
 > >  > the code is not buggy. i think u have misunderstood the real problem statement.
 > >  >
 > >  > so the problem in more detail is as below:
 > >  >
 > >  > printf("kanishk");
 > >  >
 > >  > the above code compiles perfectly with gcc -Wall.
 > >  > gcc by default puts the string into read execute segment,but i want to
 > >  > put string "kanishk" into writeable memory (or other than read execute
 > >  > segment). Is there a way for doing this without making any change in
 > >  > calling sequence (for example it may be regulated by some switch in
 > >  > gcc) or there is no provision in C99 standard for it.
 > >
 > > OK, if it's not a bug, I need to ask another question.  I don't
 > > understand you at all: why do you want to put a constant string into
 > > writable memory?    Is this embedded, or what?
 > 
 > its not.

Well, I'm about to give up, but I'll ask one last question.  You see,
the question you're asking doesn't make any sense.  No correct C or
C++ can possibly be affected by whether literal strings are in
writable memory or not, so your request is utterly baffling.  Why do
you care whether they're in writable memory?

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]