about gcc header files

Asked by prasad.ram on 2011-06-02

Hi sir i would like to add user defined header files for my functions and how it is possinble

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
Eliah Kagan
Solved:
2011-06-05
Last query:
2011-06-05
Last reply:
2011-06-02
mycae (mycae) said : #1

You have asked this, and similar questions quite a lot. You need to work some of this out for yourself.

Please revise your C/C++ books. If you do not have a C book, there is an OK one on wikibooks:
https://secure.wikimedia.org/wikibooks/en/wiki/C

prasad.ram (prasad-ram126) said : #2

sir i know the procedure in turbo c is it sufficient in ubuntu(gcc)and the
procedure is first a create a c function for which you want to make header
file in new file and and create
a header file for writing prototypes of the function and then save it then
you need to include the header file if you want to use the function (i.e
user defined function) then i would like to know how to create a header file
in gcc what is the procedure
On Thu, Jun 2, 2011 at 11:46 PM, mycae <<email address hidden>
> wrote:

> Your question #160049 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/160049
>
> Status: Open => Answered
>
> mycae proposed the following answer:
> You have asked this, and similar questions quite a lot. You need to work
> some of this out for yourself.
>
> Please revise your C/C++ books. If you do not have a C book, there is an
> OK one on wikibooks:
> https://secure.wikimedia.org/wikibooks/en/wiki/C
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/160049/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/160049
>
> You received this question notification because you asked the question.
>

It is as you have described, in gcc as well as Borland Turbo C. I have noticed that you haven't mentioned the use of header guards (also called include guards), which are important in C/C++ generally (unless you are using the #import extension, which is recommended for the Objective C and Objective C++ languages, but should probably not be used in the C and C++ languages as it is unportable). Header guards should be used whether you're using GCC, Turbo C, or any other implementation. See http://en.wikipedia.org/wiki/Include_guard.

The way header files within a program work is not very implementation-specific. It's a feature of the C language, rather than being a feature of a particular compiler.

I'd encourage you to continue asking questions, though they should be as specific as possible, and you should keep in mind that GCC has excellent documentation that you can refer to. You can also try things out--for example, you could have tried creating a simple program that contains a header file, and see if it works properly in GCC. If you had provided the information that you had provided in post #2 (as numbered at https://answers.launchpad.net/ubuntu/+source/gcc-defaults/+question/160049) in your original question, it would have been possible for us to provide a quick and complete answer much earlier. Without that information, it seemed that you were asking about an entire topic rather than something specific; in such cases, you are better off using an existing book or tutorial, rather than asking on a forum.

Something else to consider is that reading code is a great way to improve your own coding abilities, and there are many free open source software programs that are written in C and intended for compilation with GCC. (Almost all C programs of significant size contain their own header files.) Source code of free open source software is a resource that you may want to use, for reference purposes, as you continue to develop your own programming skills.

prasad.ram (prasad-ram126) said : #4

Thanks Eliah Kagan, that solved my question.