[linux-audio-dev] newest audio server for Linux (yep, yet another)

Phil Burk philburk at softsynth.com
Wed Feb 5 09:29:01 UTC 2003


> Bjarne Stroustrup who said something along the
> lines of "Every use of a define is an instance of a programmer not
> programming correctly."

Gee, thanks. But Bjarne Stroustrup was probably writing about C++, which
allows constants to be associated with a class:

    const double Synth::DEFAULT_FRAME_RATE = 44100.0;

For C++, this construct is preferable to using a #define because the scope
is limited to the class and would not conflict with, for example:

    const double Video::DEFAULT_FRAME_RATE = 30.0;

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.

    http://www.portaudio.com/docs/v19-doxydocs/portaudio_8h.html

Are enums better than #defines?? I am always trying to improve my 'C' chops
so I am open to suggestions.

Phil Burk

> > > > Imagine being able to write to an API as simple and well-designed as
> > > > this: <http://www.portaudio.com/docs/v19-doxydocs/portaudio_8h.html>
> > >
> > > Just out of interest, why are paNoDevice, paFloat32, etc, defines
> > > instead of const values?
> >
> > I don't really know.  Isn't that kind of a six/half-dozen detail?
>
> Probably.  I think it was Bjarne Stroustrup who said something along the
> lines of "Every use of a define is an instance of a programmer not
> programming correctly."  But I was just wondering if it was some
> portability thing or something.
> --
> Bob Ham <rah at bash.sh>




More information about the Linux-audio-dev mailing list