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>
.
- As a github search indicates that
inttypes.h
is included inTHGeneral.h
. - Then THXxx.h were included at https://github.com/zdevito/ATen/blob/master/src/ATen/templates/TensorDerived.h#L3
- That header is included before
#define __STDC_FORMAT_MACROS
at https://github.com/zdevito/ATen/blob/master/src/ATen/templates/TensorDerived.cpp#L9
I confirmed and suggest two solutions for this problem.
- global change:
add_definitions(-D__STDC_FORMAT_MACROS)
inCMakeLists.txt
- 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.