the role of #include

Source: Internet
Author: User

by literal meaning, unistd.h is a UNIX-defined UNIX-class system-defined symbolic constant header file, which is meant by unix-based std.

Contains function prototypes for many UNIX system services, such as the Read function, the Write function, and the Getpid function.

Reference from HTTP://HI.BAIDU.COM/W_DALU/ITEM/E8D29860374AE02369105B11

Unistd.h is similar to the windows.h! in Windows in Unix


#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

Unistd.h contains constants and functions:

ssize_t read (int, void *, size_t); Read File Usage
int unlink (const char *);
ssize_t write (int, const void *, size_t); Write a file
int Usleep (useconds_t); Process Hibernate, Unit is subtle
unsigned sleep (unsigned); Process hibernate, in seconds

int access (const char *, int); Get Permissions on files
Unsigned alarm (unsigned);
int chdir (const char *);
int chown (const char *, uid_t, gid_t);
int close (int); Close File
size_t confstr (int, char *, size_t);
void _exit (int);
pid_t fork (void);

NULL//NULL pointer
Seek_cur//Set file offset to current plus offset.
Seek_end//Set file offset to EOF plus offset.
Seek_set//SET file offset to offset.



Many of the C programs developed under Linux require header file Unistd.h, but there is no head file in VC,
So compile with VC always error. Save the following content as a unistd.h to solve this problem.
/** This file is the MINGW32 package.
* Unistd.h maps (roughly) to IO.h
*/

#ifndef _unistd_h
#define _unistd_h
#include <io.h>
#include <process.h>
#endif/* _unistd_h * *


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.