Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

c header files

Posted on 2003-02-18
2
Medium Priority
?
179 Views
Last Modified: 2010-04-17
C header files contain only function prototypes,right! Where are those functions stored?I means functions like printf and everything else?Are they stored in the C library?In those lib files?And what are those .so and .a files that you see there in the libraries, are they the functions that have already been compiled and made into objects?
0
Comment
Question by:vikasgkutty
2 Comments
 
LVL 1

Expert Comment

by:TheBeaver
ID: 7979353
Basically, you have answered the last question yourself: The functions are compiled into the lib files.
The .a files are archives ie Multiple .obj files merged into one file for sanity preservation.

Note:Not all functions have source/object code! You see, C is made up of 27 standard commands (if, else, while, etc) these are interpreted by the compiler directly.
0
 
LVL 8

Accepted Solution

by:
ssnkumar earned 150 total points
ID: 7980516
Header file contains declarations; Library contains definitions.
stdio.h contains declaration for printf().
libc.so contains the definition of printf().

There are 2 types of library files. Static library, also called as archives and they contain .a extension. And dynamic library, also called as static object and they contain extension .so.

When you compile your C program, the compiler automatically links to few library and one of them is libc.so. For other libraries such as pthread or ncurses, you will have to link them while compiling.

The compiler first looks for static object and if it is not found, then it looks for archive.

The program compiled with archive will be huge, because the library will be compiled along with the program. The program compiled with static object will be small. They will contain, just the library name and path and the actual library file will be brought to memory during runtime. And if already some program which was using that library and hence the library file was already in memory, then the same copy will be shared by both, thus saving memory.

Hope this much info is enough:-) Tell me what else you want to know!?

-Narendra
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Loops Section Overview

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question