[Ffmpeg-devel] [PATCH] video4linux2 input
Erik Slagter
erik
Tue Feb 7 12:30:31 CET 2006
On Tue, 2006-02-07 at 11:15 +0000, M?ns Rullg?rd wrote:
> Erik Slagter said:
> > On Mon, 2006-02-06 at 17:14 +0000, M?ns Rullg?rd 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?
> >>
> >> The one good thing with enums is that debugger can show the symbolic names.
> >> Apart from that, they are semantically equivalent to ints IIRC,
> >
> > Almost IIRC ;-)
>
> Here's what the ISO C99 standard has to say:
>
> The identifiers in an enumerator list are declared as constants that
> have type int and may appear wherever such are permitted. 107) An
> enumerator with = defines its enumeration constant as the value of
> the constant expression. If the first enumerator has no =, the value
> of its enumeration constant is 0. Each subsequent enumerator with no
> = defines its enumeration constant as the value of the constant
> expression obtained by adding 1 to the value of the previous
> enumeration constant. (The use of enumerators with = may produce
> enumeration constants with values that duplicate other values in the
> same enumeration.) The enumerators of an enumeration are also known
> as its members.
>
> 107) Thus, the identifiers of enumeration constants declared in the
> same scope shall all be distinct from each other and from other
> identifiers declared in ordinary declarators.
Wishful thinking I guess ;-)
> > Huh? How do you mean a #define does not pollute namespace? I'd rather
> > say that a define pollutes name space. If you're using _anything_ with
> > the same name in the same (or included!) file it will cause really
> > obscure errors!
>
> #define operates in the preprocessor namespace, which is distinct from the
> C compiler namespace. Sure, #defined names are global, but at least they
> give some additional value, such as the ability to use #ifdef. There's
> also #undef, so it's possible to clean up the namespace when you no longer
> need a particular macro.
Okay, point made, still I think it's ugly to do it with a preprocessor
construction. I won't start about C++ ;-) I know life stinks ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2771 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060207/53b7c1b0/attachment.bin>
More information about the ffmpeg-devel
mailing list