UNIX Environment Advanced programming Eclipse environment configuration plus error.cc

Source: Internet
Author: User

Apue.h#ifndef apue_sunyj#define apue_sunyjvoid err_quit (const char *fmt, ...); void Err_sys (const char *fmt, ...); #endif
Error.cpp#include <stdarg.h> #include <errno.h> #include <stdio.h> #include <string.h># Include <stdlib.h> #include <stdint.h>int64_t const MAXLINE = 4096; Max Line length/* * * Print a message and return to caller. * * Caller Specifies "Errnoflag".    * */static void Err_doit (int errnoflag, int error, const char *FMT, va_list ap) {char buf[maxline];    vsnprintf (buf, MAXLINE, FMT, AP);    if (Errnoflag) snprintf (buf + strlen (buf), Maxline-strlen (BUF), ":%s", strerror (Error));    strcat (buf, "\ n");    Fflush (stdout);/* In case stdout and stderr is the same */fputs (buf, stderr); Fflush (NULL);/* Flushes all stdio output streams */}/* * * Fatal error unrelated to a system call. * * Print a message and terminate. * */void err_quit (const char *FMT, ...)    {va_list ap;    Va_start (AP, FMT);    Err_doit (0, 0, FMT, AP);    Va_end (AP); Exit (1); Process terminate, not just like return, totally different}/* * * Fatal error related to a system call. * * Print a message and terminate. * */void Err_sys (const char *FMT, ...)    {va_list ap;    Va_start (AP, FMT);    Err_doit (1, errno, FMT, AP);    Va_end (AP); Exit (1);}

Primary purpose, in centos6.3 64-bit machines, use Eclipse to learn Apue third edition, And this study does not use the book apue.h, and some libraries under the LIB, or, is the last time the study, encountered the library is directly used, this time I put forward, an adaptation, careful of a function of learning, and use g++ compiler

UNIX Environment Advanced programming Eclipse environment configuration plus error.cc

Related Article

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.