public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "kanishk rastogi" <kanishk.85@gmail.com>
To: "Andrew Haley" <aph@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Problem with the string
Date: Fri, 24 Nov 2006 11:16:00 -0000	[thread overview]
Message-ID: <9ee2fe770611240316p30920d39nb1d28dde53936ea0@mail.gmail.com> (raw)
In-Reply-To: <17766.52089.676318.750296@zebedee.pink>

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.

>
> 8000 lines is a small piece of code, and you should be able to fix it
> in less than an hour or so.
>
> Andrew.
>
>  >
>  > thanks in advance
>  > >
>  > >  > 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:
>  > >  > >  > >  > hi all,
>  > >  > >  > >  > when we compile our c programs the strings which we use get defined in
>  > >  > >  > >  > read only memory.
>  > >  > >  > >  > how can i ask the gcc compiler to declare them in read-write section.
>  > >  > >  > >
>  > >  > >  > > You just gotta declare them right.  Like this:
>  > >  > >  > >
>  > >  > >  > > char s[] = "This is a string!";
>  > >  > >  > what abt the strings passed to functions?
>  > >  > >  > i dont want to have them in readonly menory
>  > >  > >
>  > >  > > They won't be in read-only memory: as I said, you just gotta declare
>  > >  > > them right.
>  > >  > >
>  > >  > > Andrew.
>  > >  > >
>  > >  >
>  > >  >
>  > >  > --
>  > >  > Everybody is made for some purpose. Find yours.
>  > >
>  >
>  >
>  > --
>  > Everybody is made for some purpose. Find yours.
>


-- 
Everybody is made for some purpose. Find yours.

  reply	other threads:[~2006-11-24 11:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-24  9:26 kanishk rastogi
2006-11-24  9:56 ` Andrew Haley
2006-11-24 10:15   ` kanishk rastogi
2006-11-24 10:18     ` Andrew Haley
2006-11-24 10:21       ` kanishk rastogi
2006-11-24 10:24         ` Andrew Haley
2006-11-24 10:31           ` kanishk rastogi
2006-11-24 10:37             ` Andrew Haley
2006-11-24 11:16               ` kanishk rastogi [this message]
2006-11-24 11:31                 ` Andrew Haley
2006-11-24 11:40                   ` kanishk rastogi
2006-11-24 13:33                     ` Andrew Haley
2006-11-24 15:31                       ` Segher Boessenkool
2006-11-24 18:45                 ` John (Eljay) Love-Jensen
2006-11-28  2:57 ` Michael Eager

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ee2fe770611240316p30920d39nb1d28dde53936ea0@mail.gmail.com \
    --to=kanishk.85@gmail.com \
    --cc=aph@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).