I'm making an Implementation of the Taglib C++ library. This library has a class called "Filename" used when open files from the users file system. In the source header file it says it supports
This works prefectly fine when I build the .dll while using a w_char_t file encoded string, precisely the conversion from a Godot::String, using the .unicode_str() or the Taglib::String::toCWString() function. The problem emerges when I want to build the the lib files using a Github action where it fails saying:
error: no matching function for call to ‘TagLib::Vorbis::File::File(const wchar_t*)’
772 | TagLib::Ogg::Vorbis::File OggFile(path.toCWString());
When I look into the source file however it clearly says that it's supports this encoding:
class TAGLIB_EXPORT FileName
{
public:
FileName(const wchar_t *name);
FileName(const char *name);
FileName(const FileName &name);
operator const wchar_t *() const;
operator const char *() const;
const std::wstring &wstr() const;
const std::string &str() const;
String toString() const;
private:
const std::string m_name;
const std::wstring m_wname;
};
#else
typedef const char *FileName;
#endif
Why is this constructor not supported here but on my machine? Does it have to do with the compiler? The version of the library are the exact same on my machine and within the Github Action, so the constructor should exist there too.
EDIT: The Constructor of Taglib::Vorbis::File
, and any other File within Taglib, takes a Filename
in it's Constructor for the filepath.
Here is the definition of the Taglib::Vorbis::File
as an example:
class TAGLIB_EXPORT File : public Ogg::File
{
public:
/*!
* Constructs a Vorbis file from \a file. If \a readProperties is true the
* file's audio properties will also be read.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
File(FileName file, bool readProperties = true,
Properties::ReadStyle propertiesStyle = Properties::Average);
I wanted my integration of Taglib to support all Unicode characters within Filenames, but with this error I only are able to build a release version, where the filenames are limited to ASCII-Characters.
The code snippet you've posted of the definition of FileName
leaves out the line above it: #ifdef _WIN32
(tiostream.h). But you included the #else
which makes FileName
a typedef of const char*
.
If you compile your code on Windows, FileName
will be a class that can be constructed from a const wchar_t*
or const char*
. If you don't, FileName
is just a const char*
. The latter must be the case for the Github actions that run, which is why you're getting the error.
In order to support both platforms, you can only use a const char*
here.