Questions tagged [unistd.h]

unistd.h is a C/C++ header files contains needed to provide access to the POSIX operating systems

Links:

http://en.wikipedia.org/wiki/Unistd.h

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html

150 questions
191
votes
9 answers

Is there a replacement for unistd.h for Windows (Visual C)?

I'm porting a relatively simple console program written for Unix to the Windows platform (Visual C++ 8.0). All the source files include "unistd.h", which doesn't exist. Removing it, I get complaints about misssing prototypes for 'srandom',…
AShelly
  • 32,752
  • 12
  • 84
  • 142
27
votes
2 answers

Cannot open include file: 'unistd.h': No such file or directory

After having installed libpng into my computer, I've included it into my project using #include on a Windows 7 SP1 plateform and using Visual Studio Ultimate 2013. But at build time, I'm getting this error: C1083: Cannot open include file:…
user3471387
  • 287
  • 3
  • 7
  • 10
26
votes
2 answers

How to call execl() in C with the proper arguments?

i have vlc (program to reproduce videos) if i type in a shell: /home/vlc "/home/my movies/the movie i want to see.mkv" it opens up an reproduces the movie. however, when I run the following program: #include int main(void) { …
Matias Morant
  • 473
  • 2
  • 5
  • 11
13
votes
3 answers

clang++: fatal error: 'unistd.h' file not found

Using OS X 10.10.2, I download Clang for Mac OS X v. 3.6.0, and try to compile a simple Hello World program. The commands I use are these: (assumes you downloaded clang to .) cd . ./clang+llvm-3.6.0-x86_64-apple-darwin/bin/clang++ main.cpp The…
user4664340
11
votes
3 answers

Fast input/output in competitive programming

I have come across this particular snippet of code many times in solutions of competitive programming contests. I understand the basic use of this code to beat time limits but i want to understand it more deeply. I know that unistd.h gives access to…
s2n
  • 317
  • 3
  • 9
10
votes
3 answers

C sleep function not working

When including the sleep function from unistd.h the program hangs indefinitely: #include #include int main() { int i; printf("0 "); for(i = 1; i <20; ++i) { sleep(2); …
James Jenkinson
  • 1,358
  • 2
  • 13
  • 32
9
votes
2 answers

What is the difference between fsync and syncfs?

What is the difference between fsync and syncfs ? int syncfs(int fd); int fsync(int fd); The manpage for fync says the following : fsync() transfers ("flushes") all modified in-core data of (i.e., modified buffer cache pages for) the…
cominfotty
  • 331
  • 1
  • 4
  • 9
8
votes
1 answer

Difference between unistd.h and sys/types.h in linux

When I have searched for the header unistd.h, in The Open Group, I found that it contains the standard symbolic constants & types and for sys/types.h it said for data types. Then I found that both have uid_t, pid_t and several similar types. I am…
user3511557
7
votes
1 answer

execl crashes C++ node.js-addon

As normal C++ execl works fine (compiling with g++ ok.cc -o ok.elf) #include int main(){ execl("/usr/bin/python", "/usr/bin/python", nullptr); } But crashes, when works as node.js C++ addon #include #include…
6
votes
3 answers

redirecting standard output in c then resetting standard output

I'm trying to use redirects in C to redirect input to one file and then set standard output back to print to the screen. Could someone tell me what's wrong with this code? #include #include #include int main(int argc,…
David
  • 1,715
  • 5
  • 25
  • 40
5
votes
1 answer

Clock, rdtsc and CLOCKS_PER_SEC

I am trying to implement my own version of clock() using asm and rdtsc. However I am quite unsure about its return value. Is it cycles? Oder is it micro seconds? I am also confused about CLOCKS_PER_SEC. How can this be constant? Is there any kind…
今天春天
  • 861
  • 11
  • 23
5
votes
1 answer

Attempting to use execvpe(...) but get implicit declaration error - even though I think I'm using the correct argument types

I am getting the following warning when I compile: execute.c:20:2: warning: implicit declaration of function ‘execvpe’[-Wimplicit-function-declaration] execvpe("ls", args, envp); ^ My understanding is that this occurs when the function you are…
newbie
  • 549
  • 5
  • 15
4
votes
1 answer

What does libc_hidden_proto in the glibc standard libraries do?

I was trying to look up the prototype for the getpgrp() function in unistd.h but couldnt find it. The only line containing getpgrp in that file was the line libc_hidden_proto (tcgetpgrp) and I'm assuming this is a macro, but I dont know what it…
Jerry Marbas
  • 165
  • 7
4
votes
0 answers

unistd.h file not found, clang++ and OS X

I'm currently struggling with clang++, and after looking on the web for a long time I decided asking my question. I'm on OS X and using clang++ via Emacs (it's used by flycheck to highlight errors, among other things). I have a very simple file that…
Maxime Briand
  • 41
  • 1
  • 5
4
votes
1 answer

How am I able to use read() and write() without including "unistd.h"?

I have used syscalls read() and write() in my program WITHOUT including "unistd.h" header file in the program. But still the program works and gives expected results. After running the program, i thought i will read the man page for read() and…
sps
  • 2,630
  • 1
  • 13
  • 34
1
2 3
9 10