Reputation: 111
I have this code:
#include <stdlib.h>
#include <string.h>
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>
#include <libavformat/avformat.h>
int main(int argc, char **argv)
{
avcodec_register_all();
av_register_all();
struct AVCodecTag * const *avctag;
AVOutputFormat *outputFormat = NULL;
const char *file = "file.mp4";
outputFormat = av_guess_format(0, file, 0);
if( ! outputFormat)
{
printf ("No container found\n");
exit (1);
}
printf("%s %d\n",outputFormat->long_name,outputFormat->video_codec);
avctag = outputFormat->codec_tag[0];
printf("%d\n",avctag->id);
}
The compiler gives this weird error even though I used the -> in the printf line:
error: ‘*avctag’ is a pointer; did you mean to use ‘->’?
printf("%d\n",avctag->id);
But it gives also a warning:
warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
avctag = outputFormat->codec_tag;
AVOutputFormat:codec_tag is defined according to the docs as:
struct AVCodecTag * const *
That is exactly as I defined the pointer above. Can someone give me a clue why I get the warning and the error?
Many thanks
Upvotes: 0
Views: 80
Reputation: 8142
You've got too many *
in your declaration.
outputFormat->codec_tag
is struct AVCodecTag * const *
which means that outputFormat->codec_tag[0]
is just struct AVCodecTag const *
or alternative you could do
avctag = outputFormat->codec_tag;
printf("%d\n",avctag[0]->id);
Upvotes: 1
Reputation: 310960
The pointer avctag
declared ,like a pointer to a constant pointer
struct AVCodecTag * const *avctag;
So this statement
printf("%d\n",avctag->id);
is invalid.
And you need to check the type of the right hand expression in this statement
avctag = outputFormat->codec_tag[0];
What is the type of outputFormat->codec_tag[0]
?
Upvotes: 1