[FFmpeg-devel] [PATCH 0/8] replacing #define by typedef
Ganesh Ajjanagadde
gajjanagadde at gmail.com
Thu Nov 19 14:14:07 CET 2015
#define is often abused for doing typedefs. Usually there is no issue, but the
usage is unnecessarily risky and should be avoided. Concrete example taken from
https://stackoverflow.com/questions/1666353/are-typedef-and-define-the-same-in-c:
typedef int* int_p1;
int_p1 a, b, c; // a, b, c are all pointers to int
#define int_p2 int*
int_p2 a, b, c; // only first is a pointer!
Furthermore, there is an additional advantage in that typedef respects scoping
rules while #define needs a matching undef or else is valid till the end of the
file. This simplifies slightly tests/tiny_ssim.
This series removes all such abuses of the preprocessor in FFmpeg.
Ganesh Ajjanagadde (8):
avcodec/lpc: replace #define by typedef
avcodec/aac_defines: replace #define by typedef
avcodec/ac3: replace #define by typedef
avcodec/aacps_tablegen_template: replace #define by typedef
avcodec/amr: replace #define by typedef
tests/tiny_ssim: replace #define by typedef
avcodec/faanidct: replace #define by typedef
avcodec/resample2: replace #define by typedef
libavcodec/aac_defines.h | 20 ++++++++++----------
libavcodec/aacps_tablegen_template.c | 4 ++--
libavcodec/ac3.h | 8 ++++----
libavcodec/amr.h | 4 ++--
libavcodec/faanidct.c | 2 +-
libavcodec/lpc.h | 6 +++---
libavcodec/resample2.c | 12 ++++++------
tests/tiny_ssim.c | 5 ++---
8 files changed, 30 insertions(+), 31 deletions(-)
--
2.6.2
More information about the ffmpeg-devel
mailing list