what is different unistd.h used for?

M

miloody

Dear all:
I am reading the book "advance programming in UNIX" and it say
unistd.h is posix symbolic constants.
I find all the unistd.h on my environment:
/usr/include$ find ./ -name 'unistd.h'
../asm/unistd.h
../sys/unistd.h
../unistd.h
../bits/unistd.h
../linux/unistd.h
/usr/include$

why there are so many unistd.h and under what circumstances should I
include each of them?
appreciate your help,
miloody
 
N

nicolas.sitbon

Dear all:
I am reading the book "advance programming in UNIX" and it say
unistd.h is posix symbolic constants.
I find all the unistd.h on my environment:
/usr/include$ find ./ -name 'unistd.h'
./asm/unistd.h
./sys/unistd.h
./unistd.h
./bits/unistd.h
./linux/unistd.h
/usr/include$

why there are so many unistd.h and under what circumstances should I
include each of them?
appreciate your help,
miloody

The implementation is not your problem, you should only include
unistd.h
#include <unistd.h>
 
N

Noob

miloody said:
I am reading the book "advance programming in UNIX" and it say
unistd.h is posix symbolic constants.

You'll find POSIX knowledge in a different newsgroup: comp.unix.programmer
 
R

Richard Tobin

miloody said:
I find all the unistd.h on my environment:
/usr/include$ find ./ -name 'unistd.h'
./asm/unistd.h
./sys/unistd.h
./unistd.h
./bits/unistd.h
./linux/unistd.h

The unexpected ones are part of the implementation, either included
in the real <unistd.h> or used by the Linux kernel. You should never
need to consider them for "normal" Posix C programming.

-- Richard
 
K

Keith Thompson

miloody said:
I am reading the book "advance programming in UNIX" and it say
unistd.h is posix symbolic constants.
I find all the unistd.h on my environment:
/usr/include$ find ./ -name 'unistd.h'
./asm/unistd.h
./sys/unistd.h
./unistd.h
./bits/unistd.h
./linux/unistd.h
/usr/include$

why there are so many unistd.h and under what circumstances should I
include each of them?

Questions specifically about unistd.h are best asked in
comp.unix.programmer.

More generally, though, you're probably approaching the problem from
the wrong direction. If you're writing a program that needs to call
a particular function, for example, you should read that function's
documentation to find out what header(s) you should #include.
Start from what you want to do, then find out how to do it, not
the other way around.

On the other hand, curiosity about how your implementation
does things is perfectly valid -- but any answers you get won't
necessarily be useful on other implementations.
 
K

Kenny McCormack

Keith Thompson said:
On the other hand, curiosity about how your implementation
does things is perfectly valid -- but any answers you get won't
necessarily be useful on other implementations.

In much the same way as curiosity about the weather on planet Earth is
perfectly valid, but any answers you get won't necessarily be useful on
other planets.

I.e., in case it isn't clear, who the F cares?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top