[FFmpeg-devel] On signedness of AV_NOPTS_VALUE constant

Andrey Utkin andrey.krieger.utkin at gmail.com
Tue Sep 18 20:49:03 CEST 2012


 $ cat signedness.c
#include <libavutil/avutil.h>
int main() {
  int64_t pts = 0;
  if (pts == AV_NOPTS_VALUE)
    return 1;
  return 0;
}

Compiling with -Wextra gives a warning:

 $ LC_ALL= LANG= gcc -c signedness.c -Wall -Wextra
signedness.c: In function 'main':
signedness.c:4:11: warning: comparison between signed and unsigned
integer expressions

Why this gives warning? The constant is defines as INT64_C(0x8000000000000000)
Preprocessor produces such code:
int main() {
  int64_t pts = 0;
  if (pts == 0x8000000000000000L)
    return 1;
  return 0;
}

It is strange to me that compiler treats this constant as unsigned.
And i think this is not my personal problem - we use this constant
widely, but timestamps are stored mostly in int64_t variables. It
would be ideal to pass this without warnings on high warning level.
-- 
Andrey Utkin


More information about the ffmpeg-devel mailing list