一见

PRId64的正确用法

#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>


// g++ -g -o x x.cpp -D__STDC_FORMAT_MACROS -std=c++11
int main()
{
        int64_t a = 32;
        //printf("%"PRId64"\n", a);
        printf("%" PRId64"\n", a); // 在PRId64前保留一个空格
        // 如果不保留空格,则C++11编译时将报如下警告:
        // invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
        // 将PRId64换成其它宏,情况相同
        return 0;
}

posted on 2016-08-25 13:28  -见  阅读(3261)  评论(0编辑  收藏  举报

导航