The problem with void* is that any pointer can be implicitly converted to it, making it very type-unsafe. You could write the following and the compiler won't bat an eye:
int a;
Pa_GetStreamInfo(&a);
I believe it would be more developer-friendly to make PaStream a type-safe opaque type, for example:
typedef struct PaStream PaStream;
This change shouldn't break anyone as long as user code does not rely on PaStream specifically being an alias to void - which seems unlikely. If it does break it's a compile-time error so it shouldn't take anyone by surprise.
In dechamps/FlexASIO@59f75ce183431f8b50f7f209790090c5a608b08e, I introduced a severe bug (dechamps/FlexASIO#231) because I accidentally wrote:
Instead of:
It is very sad that the obviously wrong code was able to compile.
The reason why that code managed to sift through the cracks is because
PaStream*
is defined asvoid*
:https://github.com/PortAudio/portaudio/blob/18a606e1f928852bfc29639d9539ae74d37b5dee/include/portaudio.h#L639
The problem with
void*
is that any pointer can be implicitly converted to it, making it very type-unsafe. You could write the following and the compiler won't bat an eye:I believe it would be more developer-friendly to make
PaStream
a type-safe opaque type, for example:This change shouldn't break anyone as long as user code does not rely on
PaStream
specifically being an alias tovoid
- which seems unlikely. If it does break it's a compile-time error so it shouldn't take anyone by surprise.