zoukankan      html  css  js  c++  java
  • APUE_eclipse环境配置加上error.cc apuesunyj.h

    $_09]TZIKQ4UAT1$8IEGL%G

    RZD7I{I]$YZWV7]L1[}3@_4

    _VKFHGZYC6LAB[[01})U0M8

    {3)WS`8}4SJ})Z$TG1D@4G7

    // apuesunyj.h
    #ifndef APUE_SUNYJ
    #define APUE_SUNYJ
    
    #include <errno.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdarg.h>
    #include <stdlib.h>
    #include <stdint.h>
    
    void err_quit(const char *fmt, ...);
    void err_sys(const char *fmt, ...);
    
    
    #endif
     1 // error.cpp
     2 #include "apuesunyj.h"
     3 
     4 int64_t const MAXLINE = 4096; // max line length
     5 /*
     6  *  * Print a message and return to caller.
     7  *   * Caller specifies "errnoflag".
     8  *    */
     9 static void err_doit(int errnoflag, int error, const char *fmt, va_list ap)
    10 {
    11     char buf[MAXLINE];
    12 
    13     vsnprintf(buf, MAXLINE, fmt, ap);
    14     if (errnoflag)
    15         snprintf(buf + strlen(buf), MAXLINE - strlen(buf), ": %s", strerror(
    16                     error));
    17     strcat(buf, "
    ");
    18     fflush(stdout);/* in case stdout and stderr are the same */
    19     fputs(buf, stderr);
    20     fflush(NULL);/* flushes all stdio output streams */
    21 }
    22 
    23 /*
    24  *  * Fatal error unrelated to a system call.
    25  *   * Print a message and terminate.
    26  *    */
    27 void err_quit(const char *fmt, ...)
    28 {
    29     va_list ap;
    30 
    31     va_start(ap, fmt);
    32     err_doit(0, 0, fmt, ap);
    33     va_end(ap);
    34     exit(1) ; // process terminate, not just like return, totally different
    35 }
    36 
    37 /*
    38  *  * Fatal error related to a system call.
    39  *   * Print a message and terminate.
    40  *    */
    41 void err_sys(const char *fmt, ...)
    42 {
    43     va_list ap;
    44 
    45     va_start(ap, fmt);
    46     err_doit(1, errno, fmt, ap);
    47     va_end(ap);
    48     exit(1) ;
    49 }
    # libApueSunyj.a
    libApueSunyj.a: error.o
        ar cr libApueSunyj.a error.o
    error.o: error.cpp apuesunyj.h
        g++ -c -g error.cpp -o error.o
    clean:
        rm error.o libApueSunyj.a


    主要目的,在centos6.3 64位机器中,使用eclipse学习APUE第三版,且这次学习不使用书中自带的apue.h,与lib下的一些库,或者说,是上一次学习的时候,碰到的库是直接用的,这次我全部提出来,一个一个的改编,细心的一个一个函数的学习,且使用g++编译器

    191594

    212911222820228828247530

  • 相关阅读:
    BestCoder Round #87 1001
    p1304 家族
    hdu 1003
    hdu 1231
    hdu 1232 畅通工程
    hdu 4107
    Robot Framework--用例、数据、流程分离例子
    Robot Framework--RIDE面板与库的说明
    Robot Framework--pybot命令
    Robot Framework--运行pybot时出错
  • 原文地址:https://www.cnblogs.com/sunyongjie1984/p/4284479.html
Copyright © 2011-2022 走看看