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',…
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:…
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) {
…
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…
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…
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);
…
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…
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…
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,…
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…
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…
In my code I need to execute /bin/bash, but I wan't to do it without passing any arguments to it. I wrote this:
execl("/bin/bash", NULL);
Then, through some research, I realized that I also need to add type cast:
execl("bin/bash", (char*)…
Suppose two different processes open the same file independently, and so have different entries in the Open file table (system-wide). But they refer to the same i-node entry.
As the file descriptors refer to the different entries in the Open file…
GNU unistd.h has this bit of magic:
/* Move FD's file position to OFFSET bytes from the
beginning of the file (if WHENCE is SEEK_SET),
the current position (if WHENCE is SEEK_CUR),
or the end of the file (if WHENCE is SEEK_END).
Return…
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…