zoukankan      html  css  js  c++  java
  • Thrift-0.10.0 CenOS 7 编译错误 error: expected ')' before 'PRIu32'

    Thrift-0.10.0 CenOS 7 编译错误 error: expected ')' before 'PRIu32'

      在编译Thrift的时候,无论是Apache官网tar包,还是Github镜像,都会出现各种错误,其中一个比较头疼的就是标题描述的编译错误,经过捣鼓,终于妥协性的搞定了。

      make时的错误描述: 

        src/thrift/server/TNonblockingServer.cpp: In member function 'void apache::thrift::server::TNonblockingServer::TConnection::workSocket()':
        src/thrift/server/TNonblockingServer.cpp:460:16: error: expected ')' before 'PRIu32'
        "(%" PRIu32 " > %" PRIu64

      问题原因:

        使用PRIu32进行格式化的输出的时候需要引用:#include <inttypes.h>

        需要同时增加编译宏:__STDC_FORMAT_MACROS

        但是这里有一个问题,这个编译宏必须添加在#include <inttypes.h>之前,否则无效,如果工程比较大的时候,这样就需要保证在第一次引用#include <inttypes.h>之前添加这个编译宏。

        详细信息可以参考stackoverflow

      问题解决方法:

        这个错误出现在编译 src/thrift/server/TNonblockingServer.cpp 文件时,但是在这个文件中的#include <inttypes.h>之前增加编译宏 __STDC_FORMAT_MACROS 是不起作用的,最后搜索了所有包含inttypes.h的所有文件,尝试着更改了文件:src/thrift/Thrift.h,最后编译成功,更改内容如下:

        #ifdef HAVE_INTTYPES_H

        #define __STDC_FORMAT_MACROS

        #include <inttypes.h>
        #endif

     

  • 相关阅读:
    python学习笔记二--列表
    python学习笔记一--字符串
    写点什么呢
    nagios&pnp4nagios--yum 安装
    敏捷开发的思路
    Foreman--管理PuppetClient
    url编码解码的问题(urlencode/quote)
    json数据的处理和转化(loads/load/dump/dumps)
    http和https的区别
    python中requests的用法总结
  • 原文地址:https://www.cnblogs.com/wanghaiyang1930/p/6404847.html
Copyright © 2011-2022 走看看