zdevito / ATen

ATen: A TENsor library for C++11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PRId64 (__STDC_FORMAT_MACROS) in older g++ again

ShigekiKarita opened this issue · comments

related to this issue pytorch/pytorch#3571
Since header organization is changed, this happens again in my CentOS7 & GCC4.8.5.

The problem is that __STDC_FORMAT_MACROS is defined after #include <inttypes.h>.

I confirmed and suggest two solutions for this problem.

  1. global change: add_definitions(-D__STDC_FORMAT_MACROS) in CMakeLists.txt
  2. local change: #define __STDC_FORMAT_MACROS before $th_headers at https://github.com/zdevito/ATen/blob/master/src/ATen/templates/TensorDerived.h#L3 (also suggested in pytorch/pytorch#3949 (comment))

I prefer 1st one because it covers every header files while you use CMake.

Thank you! That helps a lot! It would be better if anyone could merge this change.