zoukankan      html  css  js  c++  java
  • Linux

    本文转载自:http://blog.csdn.net/hadas_wang/article/details/43203795

    1. 下载代码:http://www.apuebook.com/code3e.html

    2. 安装依赖库:sudo apt-get install libbsd-dev 

    3. 进入下载目录make

    4. 复制头文件和动态链接库

    [plain] view plaincopy在CODE上查看代码片派生到我的代码片
     
     
    1. sudo cp ./include/apue.h /usr/include/  
    2. sudo cp ./lib/libapue.a /usr/local/lib/  
    3. sudo cp ./lib/libapue.a /usr/lib/  

    5. 设置错误文件error.h

    [cpp] view plaincopy在CODE上查看代码片派生到我的代码片
     
     
    1. #include "apue.h"  
    2. #include <errno.h>      /* for definition of errno */  
    3. #include <stdarg.h>     /* ISO C variable aruments */  
    4.   
    5. static void err_doit(int, int, const char *, va_list);  
    6.   
    7. /* 
    8.  * Nonfatal error related to a system call. 
    9.  * Print a message and return. 
    10.  */  
    11. void err_ret(const char *fmt, ...)  
    12. {  
    13.     va_list     ap;  
    14.   
    15.     va_start(ap, fmt);  
    16.     err_doit(1, errno, fmt, ap);  
    17.     va_end(ap);  
    18. }  
    19.   
    20.   
    21. /* 
    22.  * Fatal error related to a system call. 
    23.  * Print a message and terminate. 
    24.  */  
    25. void err_sys(const char *fmt, ...)  
    26. {  
    27.     va_list     ap;  
    28.   
    29.     va_start(ap, fmt);  
    30.     err_doit(1, errno, fmt, ap);  
    31.     va_end(ap);  
    32.     exit(1);  
    33. }  
    34.   
    35.   
    36. /* 
    37.  * Fatal error unrelated to a system call. 
    38.  * Error code passed as explict parameter. 
    39.  * Print a message and terminate. 
    40.  */  
    41. void err_exit(int error, const char *fmt, ...)  
    42. {  
    43.     va_list     ap;  
    44.   
    45.     va_start(ap, fmt);  
    46.     err_doit(1, error, fmt, ap);  
    47.     va_end(ap);  
    48.     exit(1);  
    49. }  
    50.   
    51.   
    52. /* 
    53.  * Fatal error related to a system call. 
    54.  * Print a message, dump core, and terminate. 
    55.  */  
    56. void err_dump(const char *fmt, ...)  
    57. {  
    58.     va_list     ap;  
    59.   
    60.     va_start(ap, fmt);  
    61.     err_doit(1, errno, fmt, ap);  
    62.     va_end(ap);  
    63.     abort();        /* dump core and terminate */  
    64.     exit(1);        /* shouldn't get here */  
    65. }  
    66.   
    67.   
    68. /* 
    69.  * Nonfatal error unrelated to a system call. 
    70.  * Print a message and return. 
    71.  */  
    72. void err_msg(const char *fmt, ...)  
    73. {  
    74.     va_list     ap;  
    75.   
    76.     va_start(ap, fmt);  
    77.     err_doit(0, 0, fmt, ap);  
    78.     va_end(ap);  
    79. }  
    80.   
    81.   
    82. /* 
    83.  * Fatal error unrelated to a system call. 
    84.  * Print a message and terminate. 
    85.  */  
    86. void err_quit(const char *fmt, ...)  
    87. {  
    88.     va_list     ap;  
    89.   
    90.     va_start(ap, fmt);  
    91.     err_doit(0, 0, fmt, ap);  
    92.     va_end(ap);  
    93.     exit(1);  
    94. }  
    95.   
    96.   
    97. /* 
    98.  * Print a message and return to caller. 
    99.  * Caller specifies "errnoflag". 
    100.  */  
    101. static void err_doit(int errnoflag, int error, const char *fmt, va_list ap)  
    102. {  
    103.     char    buf[MAXLINE];  
    104.    vsnprintf(buf, MAXLINE, fmt, ap);  
    105.    if (errnoflag)  
    106.        snprintf(buf+strlen(buf), MAXLINE-strlen(buf), ": %s",  
    107.          strerror(error));  
    108.    strcat(buf, " ");  
    109.    fflush(stdout);     /* in case stdout and stderr are the same */  
    110.    fputs(buf, stderr);  
    111.    fflush(NULL);       /* flushes all stdio output streams */  
    112. }  


    6. 注销,重启

    7. 代码文件

    [cpp] view plaincopy在CODE上查看代码片派生到我的代码片
     
     
      1. #include "apue.h"  
      2. #include "error.h"  
  • 相关阅读:
    一次惨痛的debug的经历-RuntimeError: CUDA error: an illegal memory access was encountered
    Rank loss调研
    守护进程 supervisor
    PHP实现异步请求非阻塞
    PHP实现图片和文字水印(PHP给图片添加水印功能)
    虚拟机相关博客
    小师妹学JavaIO之:文件系统和WatchService
    后端 Java ActionEvent getModifiers()
    Java中常见的锁简述
    关键系统的JVM参数推荐
  • 原文地址:https://www.cnblogs.com/zzb-Dream-90Time/p/6815834.html
Copyright © 2011-2022 走看看