[alsa-devel] dereferencing pointer error in app but not in lib
In the library, like pcm.c I can code like
const char *snd_pcm_name(snd_pcm_t pcm) { return pcm->name; }
At the same time, the same code in the application causes "dereferencing pointer to incomplete type" error. Note, the compiler does not tell that there is no such field in the pcm structure. It just thinks that the name has another type. Which one?
thank you.
intellij wrote:
In the library, like pcm.c I can code like
const char *snd_pcm_name(snd_pcm_t pcm) { return pcm->name; }
At the same time, the same code in the application causes "dereferencing pointer to incomplete type" error. Note, the compiler does not tell that there is no such field in the pcm structure. It just thinks that the name has another type. Which one?
The type is the same, it's just incomplete (= not yet defined). The library does this to prevent applications from accessing the fields so that the API stays binary compatible.
HTH Clemens
participants (2)
-
Clemens Ladisch
-
intellij