[linux-audio-dev] newest audio server for Linux (yep, yet another)
Nathaniel Virgo
nathaniel.virgo at ntlworld.com
Wed Feb 5 14:42:01 UTC 2003
On Wednesday 05 February 2003 6:18 pm, Tim Hockin wrote:
> > That is a great feature of C++ but PortAudio is using 'C' not C++. So I
> > think our only choices are #define and enum. PortAudio uses both.
>
> you can still use const variables - gcc with optimizations treats them like
> defines, but with type-safety.
Consts are slightly different in standard C, though - they are treated as
ordinary variables that can't be changed. This means that in some non-gcc
compilers you can't say
const int a=10;
/* ... */
int n[a];
like you can in C++ or gcc without the --pedantic option. That's why you'll
often see enums used to specify array bounds in portable code.
> > Are enums better than #defines?? I am always trying to improve my 'C'
> > chops so I am open to suggestions.
only in that macros are generally a Bad Thing.
++templates_are_cool;, by the way ;)
> If you can enumerate the values, you should, IMHO. Of course, there are
> times to break this, but in general YES. An enum is a real type, and can
> be used as such.
>
> enum foo_cmd {
> FOO_A,
> FOO_B,
> FOO_C,
> };
> int doo_foo_cmd(enum foo_cmd cmd);
>
>
> Tim
More information about the Linux-audio-dev
mailing list