standard header files

Discussion in 'C Programming' started by jayceechong@gmail.com, Jan 20, 2006.

  1. Guest

    If I write my own C compiler, can I just "take" existing standard
    header files (e.g. stdio.h, stdlib.h, etc.) from an existing C compiler
    and plug them in my own? I understand I have to write my own library
    implementations, but what about these header files? Thanks!
     
    , Jan 20, 2006
    #1
    1. Advertising

  2. writes:
    > If I write my own C compiler, can I just "take" existing standard
    > header files (e.g. stdio.h, stdlib.h, etc.) from an existing C compiler
    > and plug them in my own? I understand I have to write my own library
    > implementations, but what about these header files? Thanks!


    Maybe.

    Note that the standard headers don't necessarily have to be files,
    though they usually are.

    If the header files already on the system don't use any
    compiler-specific features (or use them only protected by appropriate
    #ifdefs), you should be ok. Or you might do something like gcc's
    "fix-headers", which, during installation, makes modified copies of
    the system headers.

    For that matter, there's no real reason why you should have to write
    your own library implementations. gcc, for example, uses whatever C
    library exists on the system.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Jan 20, 2006
    #2
    1. Advertising

  3. Michael Mair Guest

    wrote:
    > If I write my own C compiler, can I just "take" existing standard
    > header files (e.g. stdio.h, stdlib.h, etc.) from an existing C compiler
    > and plug them in my own? I understand I have to write my own library
    > implementations, but what about these header files? Thanks!


    There is no requirement at all that these other header files
    - exist (the compiler may implement them internally)
    - contain standard C (black magic may be used)
    - will work with any other C compiler

    It may be instructive to have a look at these headers and
    copy function prototypes and standard macro definitions
    (or strip other things) but you should not take them as
    they are without having a look.

    Alternatively, do what a good compiler writer does and have
    a look at the C standard. The C99 standard is available as
    PDF for 18 USD, the last public draft, N869.pdf, for free.
    If you want, have a look at N1124.pdf, the current last
    public draft.

    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
     
    Michael Mair, Jan 20, 2006
    #3
  4. CBFalconer Guest

    wrote:
    >
    > If I write my own C compiler, can I just "take" existing standard
    > header files (e.g. stdio.h, stdlib.h, etc.) from an existing C
    > compiler and plug them in my own? I understand I have to write my
    > own library implementations, but what about these header files?


    Since the headers describe the library, what do you think?

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
     
    CBFalconer, Jan 20, 2006
    #4
  5. osmium Guest

    <> wrote:

    > If I write my own C compiler, can I just "take" existing standard
    > header files (e.g. stdio.h, stdlib.h, etc.) from an existing C compiler
    > and plug them in my own? I understand I have to write my own library
    > implementations, but what about these header files? Thanks!


    I don't know what prompted the question. But if it is from a
    patent/copyright point of view, I don't think any person or organization
    owns the intellectual property contained in ISO whatever. I would much
    prefer using that as a source to some actual implantation, it seems a lot
    safer and better in the long run.

    IANAL. Thank God.
     
    osmium, Jan 20, 2006
    #5
  6. Michael Mair wrote:
    >
    > wrote:
    > > If I write my own C compiler, can I just "take" existing standard
    > > header files (e.g. stdio.h, stdlib.h, etc.) from an existing C compiler
    > > and plug them in my own? I understand I have to write my own library
    > > implementations, but what about these header files? Thanks!

    >
    > There is no requirement at all that these other header files
    > - exist (the compiler may implement them internally)
    > - contain standard C (black magic may be used)
    > - will work with any other C compiler


    Well, he did say "if I write my own C compiler". So, even if the headers
    do contain black magic, they can still work with his compiler as long as
    he implements the same black magic.

    Of course, he might not be able to distribute those header files if they're
    copyrighted.

    [...]

    --
    +-------------------------+--------------------+-----------------------------+
    | Kenneth J. Brody | www.hvcomputer.com | |
    | kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------------+
    Don't e-mail me at: <mailto:>
     
    Kenneth Brody, Jan 20, 2006
    #6
    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. DrUg13
    Replies:
    1
    Views:
    497
    DrUg13
    Feb 10, 2004
  2. ambika

    non-standard header files

    ambika, Aug 26, 2003, in forum: C Programming
    Replies:
    2
    Views:
    367
    Malcolm
    Aug 26, 2003
  3. John Smith

    Header files included in header files

    John Smith, Jul 21, 2004, in forum: C Programming
    Replies:
    18
    Views:
    639
    Jack Klein
    Jul 24, 2004
  4. Replies:
    3
    Views:
    1,360
    Walter Roberson
    May 1, 2006
  5. mlt
    Replies:
    2
    Views:
    917
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page