473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

standard header files

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 '06 #1
5 1952
ja*********@gmail.com 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) ks***@mib.org <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.
Jan 20 '06 #2
ja*********@gmail.com 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.
Jan 20 '06 #3
ja*********@gmail.com 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/>
Jan 20 '06 #4
<ja*********@gmail.com> 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.
Jan 20 '06 #5
Michael Mair wrote:

ja*********@gmail.com 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:Th*************@gmail.com>
Jan 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Web Developer | last post by:
Hi, In Java, the package java.lang.*; is automatically imported and provides a basic set of functionality. Questions: 1) In C++, are there any include files that are automatically included?...
71
by: Christopher Benson-Manica | last post by:
At what point was the .h dropped from the STL headers? I just had a discussion yesterday with my boss, who said he wanted .h on all the STL includes, despite me protesting that it was not...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
2
by: ambika | last post by:
Am just a beginner. Can someone please help me know what do non-standard header files mean??? I include the header file "conio.h" in my program.I was told that this is a non-standard header file...
11
by: BilfFord X | last post by:
If I # include "text.h" , where text.h consists of the following: # define NOTHING_IMPORTANT # include <stdio.h> , am I writing c++? cordially, bfx
2
by: sharpblade | last post by:
The title of these Item is "Make header files self-sufficient" There're two examples in this Item: Example 1: Dependent names. Templates are compiled at the point where they are defined, except...
7
by: David T. Ashley | last post by:
Are the standard header files (<stdio.hfor example) always safe to include more than once? Is this just good programming practice on the part of the average person who writes these things, or is...
2
by: Devine123 | last post by:
Hi, I’m creating a perl script that takes incoming http/s requests, logs the standard input, output and error, before returning the output to the client. The input, output and error log is appended...
6
by: Ole Nielsby | last post by:
The standard doesn't define this but what conventions do projects use? As I understand it, #include <somelibrary.h> is used for including system headers and those of frameworks such as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.