C function call from C ++, error "without corresponding function"

I defined the following header file (in C), did not use the implementation of the function, since this is not required:

#ifndef FFMPEG_MEDIAMETADATARETRIEVER_H_ #define FFMPEG_MEDIAMETADATARETRIEVER_H_ #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libavutil/dict.h> int setDataSource(AVFormatContext** pFormatCtx, const char* path); #endif /*FFMPEG_MEDIAMETADATARETRIEVER_H_*/ 

In C ++, I defined my second header file:

 #ifndef MEDIAMETADATARETRIEVER_H #define MEDIAMETADATARETRIEVER_H using namespace std; extern "C" { #include "ffmpeg_mediametadataretriever.h" } class MediaMetadataRetriever { public: MediaMetadataRetriever(); ~MediaMetadataRetriever(); int setDataSource(const char* dataSourceUrl); }; #endif // MEDIAMETADATARETRIEVER_H 

In, mediametadataretriever.cpp I defined the following function:

 int MediaMetadataRetriever::setDataSource( const char *srcUrl) { // should call C function AVFormatContext* pFormatCtx; return setDataSource(&pFormatCtx, srcUrl); } 

When I try to compile this (C ++) project in Eclipse, I get the error message "There is no function matching ..." associated with:

 return setDataSource(&pFormatCtx, srcUrl); 

If I comment on the call, the code compiles fine:

 int MediaMetadataRetriever::setDataSource( const char *srcUrl) { return 0; } 

This seems to be a binding problem, does anyone know what I'm doing wrong?

+4
source share
1 answer

setDataSource in this context is the name of a member function. To call a free function, try defining its name completely:

 return ::setDataSource(&pFormatCtx, srcUrl); // ^^ 
+14
source

All Articles