[Ffmpeg-devel] [PATCH] video4linux2 input

Måns Rullgård mru
Tue Feb 7 11:38:07 CET 2006


Erik Slagter said:
> On Mon, 2006-02-06 at 12:06 -0500, Rich Felker wrote:
>> > To be even more elegant, I'd use a enum AND a table. #define's for
>> > constants are evil, indeed.
>>
>> Do you have any good reason to say this or is it just more CS dogma?
>
> Tables: less executable code -> less maintenance and bugs, if one entry
> works, all work.

Tables are good.

> #defines: using #define for constants is reducing the C compiler to a
> super-assembler. If someone likes to program assembler, one should
> actually use the assembler and not misuse cpp for that purpose. C does
> have a notion of types (although not strongly enforced -- a shame) and
> using #defines you're totally defeating any sense of types. Also, if
> used heavily, the code is really difficult to debug, gcc -E output is
> not pretty.

Enums are treated exactly like ints.  An enum type can be assigned any
value, and any enum types are automatically converted to other integer
types.  There is one difference: some versions of gcc will warn if and
enum is used in a switch statement, and there isn't a case for each value
of the enum type or a default label.  This warning is of questionable
value, and ffmpeg explicitly disables it.

-- 
M?ns Rullg?rd
mru at inprovide.com





More information about the ffmpeg-devel mailing list