Segment

Discussion in 'C Programming' started by raghu, Dec 28, 2006.

  1. raghu

    raghu Guest

    Can anyone please tell me what are the different segments in a C
    program? Where can I find more details regarding this?

    Please help.

    Merry Christmas and Happy New Year

    Regards,
    Raghu
     
    raghu, Dec 28, 2006
    #1
    1. Advertising

  2. In article <>,
    raghu <> wrote:
    >Can anyone please tell me what are the different segments in a C
    >program? Where can I find more details regarding this?


    The C standard says nothing about "segments" for C programs.
    Anything having to do with "segments" is system-specific, and
    you need to read the documentation for your system.

    See also
    http://groups.google.ca/group/comp.lang.c/browse_thread/thread/872eceed7a419316
    --
    All is vanity. -- Ecclesiastes
     
    Walter Roberson, Dec 28, 2006
    #2
    1. Advertising

  3. "raghu" <> wrote in message
    news:...
    > Can anyone please tell me what are the different segments in a C
    > program? Where can I find more details regarding this?


    You may find this page interesting reading:

    http://www.ualberta.ca/CNS/RESEARCH/LinuxClusters/mem.html

    "Segment" is a very system-specific notion. Some systems historically have
    had shared "segments" optimized linking, loading, running common programs,
    etc. in various ways.

    Some systems historically have also had hardware limitations on the amount
    of memory that could be in a segment, leading to various ways of linking and
    loading large programs.

    http://en.wikipedia.org/wiki/Memory_segment

    Generally, any small 'C' program is going to have at minimum a)executable
    code, b)stack, and c)memory for static and global variables.

    Understanding the ELF format is a good first step.
     
    David T. Ashley, Dec 28, 2006
    #3
  4. raghu said:

    > Can anyone please tell me what are the different segments in a C
    > program?


    The term is not used within the C language specification. We have functions,
    if that's any help to you.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Dec 28, 2006
    #4
  5. In article <>,
    Richard Heathfield <> wrote:
    >raghu said:


    >> Can anyone please tell me what are the different segments in a C
    >> program?


    >The term is not used within the C language specification. We have functions,
    >if that's any help to you.


    I note the local man pages use the term in at least one place:

    strspn (or strcspn) returns the length of the initial segment of string
    s1 which consists entirely of characters from (not from) string s2.

    I don't have my Standard available to check the official wording.
    --
    I was very young in those days, but I was also rather dim.
    -- Christopher Priest
     
    Walter Roberson, Dec 28, 2006
    #5
  6. Walter Roberson said:

    > In article <>,
    > Richard Heathfield <> wrote:
    >>raghu said:

    >
    >>> Can anyone please tell me what are the different segments in a C
    >>> program?

    >
    >>The term is not used within the C language specification. We have
    >>functions, if that's any help to you.

    >
    > I note the local man pages use the term in at least one place:
    >
    > strspn (or strcspn) returns the length of the initial segment of
    > string s1 which consists entirely of characters from (not from)
    > string s2.
    >
    > I don't have my Standard available to check the official wording.


    I am guilty of jumping to a conclusion. The Standard does indeed use the
    term 'segment' in the docs for strcspn and strspn, to refer to the first
    part of a string.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Dec 28, 2006
    #6
  7. "Richard Heathfield" <> wrote in message
    news:...
    > Walter Roberson said:
    >
    >> In article <>,
    >> Richard Heathfield <> wrote:
    >>>raghu said:

    >>
    >>>> Can anyone please tell me what are the different segments in a C
    >>>> program?

    >>
    >>>The term is not used within the C language specification. We have
    >>>functions, if that's any help to you.

    >>
    >> I note the local man pages use the term in at least one place:
    >>
    >> strspn (or strcspn) returns the length of the initial segment of
    >> string s1 which consists entirely of characters from (not from)
    >> string s2.
    >>
    >> I don't have my Standard available to check the official wording.

    >
    > I am guilty of jumping to a conclusion. The Standard does indeed use the
    > term 'segment' in the docs for strcspn and strspn, to refer to the first
    > part of a string.


    Ah ... actually, you were right the first time. The term as the OP intended
    is not really used.

    It depends on whether you interpret "term" to be (the literal word) or (a
    particular meaning of a word that can have several meanings). In this case
    I'd support the second definition.

    The OP intended "segment" as used in linker documentation or machine
    architecture, things like ".data", ".bss", etc.

    "segment" as cited above means "contiguous portion" or "subset" ... somewhat
    different than the linker meaning.

    If the specification includes an appendix on human parasitic infections and
    they mention "segment" of a tapeworm, would it be fair to say that a
    "segment" when talking about a tapeworm is different than a "segment" when
    talking about a linker map? ... I kind of think they are different.
     
    David T. Ashley, Dec 29, 2006
    #7
  8. In article <3z0lh.24425$>,
    David T. Ashley <> wrote:
    >>>>raghu said:


    >>>>> Can anyone please tell me what are the different segments in a C
    >>>>> program?


    >If the specification includes an appendix on human parasitic infections and
    >they mention "segment" of a tapeworm, would it be fair to say that a
    >"segment" when talking about a tapeworm is different than a "segment" when
    >talking about a linker map? ... I kind of think they are different.


    That's fine, but the original poster did not say anything about
    linker maps. I have quoted what was actually said, above.
    If "segment" is mentioned only in connection with str[c]spn, then
    it is only in connection with uses of str[c]spn that one has
    "different segments in a C program".


    (To clarify my position, I was the first to reply, and I posted a
    "that's system specific; see further discussion at" answer. But then
    I nitpicked Richard's answer, seeing as "Free Nitpicking!" is the
    official newsgroup motto ;-) )
    --
    There are some ideas so wrong that only a very intelligent person
    could believe in them. -- George Orwell
     
    Walter Roberson, Dec 29, 2006
    #8
  9. David T. Ashley said:

    > "Richard Heathfield" <> wrote in message
    > news:...


    <snip>

    >> I am guilty of jumping to a conclusion. The Standard does indeed use the
    >> term 'segment' in the docs for strcspn and strspn, to refer to the first
    >> part of a string.

    >
    > Ah ... actually, you were right the first time.


    No, I was wrong. The term *is* used within the C spec.

    > The term as the OP intended is not really used.


    Probably true, and that's why I replied as I did originally. Nevertheless,
    we only know what he said, not what he meant.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Dec 29, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bob
    Replies:
    6
    Views:
    26,914
    G. G. Ditzel
    Nov 25, 2003
  2. Fangs
    Replies:
    3
    Views:
    9,841
    darshana
    Oct 26, 2008
  3. KBuser
    Replies:
    0
    Views:
    407
    KBuser
    Apr 5, 2006
  4. Aaron P Frenger

    Using schema to validate xml file segment

    Aaron P Frenger, Nov 4, 2004, in forum: XML
    Replies:
    0
    Views:
    518
    Aaron P Frenger
    Nov 4, 2004
  5. Stephen S M WONG

    C++ implementation on segment model

    Stephen S M WONG, Feb 24, 2004, in forum: C++
    Replies:
    3
    Views:
    2,603
    John Harrison
    Feb 25, 2004
Loading...

Share This Page