Community
cancel
Showing results for 
Search instead for 
Did you mean: 
albl500
Beginner
140 Views

Linux C++ Class templates

Hi,

I'm trying to compile <a href="http://taglib.github.com/">TagLib</a>, a dependency of VLC, and get the error below during the build.

If I replace `icpc` with `g++ -O3`, the compilation works fine. This has already been mentioned in <a href="http://old.nabble.com/-Bug-139190--New%3A-taglib-won%27t-compile-with-intel-c%2B%2B-compiler-td8040449.html"a thread to the TagLib developers</a>, but they don't seem to care enough to want to fix it.
Is there an icpc option that will fix this, or is this a bug / limitation in Intel's implementation? I don't know C++ well enough to fix this myself, but upload the files mentioned in the error message.
Is this <a href="http://software.intel.com/en-us/articles/template-function-with-default-argument-in-a-template-class">Intel article</a> describing the same issue?


Cheers,
Alex


cd /usr/local/src/AV/vlc/contrib/build/taglib/taglib && /opt/intel/bin/icpc   -DTAGLIB_STATIC -DHAVE_CONFIG_H -I/usr/local/src/AV/vlc/contrib/x86_64-linux-gnu/include -g -fPIC  -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib -I/usr/local/src/AV/vlc/contrib/build/taglib -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/asf -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/ogg -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/ogg/flac -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/flac -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpc -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/mp4 -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/ogg/vorbis -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/ogg/speex -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg/id3v2 -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg/id3v2/frames -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg/id3v1 -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/ape -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/wavpack -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/trueaudio -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/riff -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/riff/aiff -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/riff/wav -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/mod -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/s3m -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/it -I/usr/local/src/AV/vlc/contrib/build/taglib/taglib/xm    -o CMakeFiles/tag.dir/mpeg/mpegfile.cpp.o -c /usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg/mpegfile.cpp
/usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg/id3v1/id3v1tag.h(62): warning #161: unrecognized #pragma
        TAGLIB_IGNORE_MISSING_DESTRUCTOR
        ^

/usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.tcc(66): error #308: class template "TagLib::List<T>::ListPrivate [with T=TagLib::ByteVector]" (declared at line 245 of "/usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.h") is inaccessible
  template <class TP> class List<T>::ListPrivate<TP *>  : public ListPrivateBase
                                     ^
          detected during instantiation of class "TagLib::List<T> [with T=TagLib::ByteVector]" at line 41 of "/usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tbytevectorlist.h"

compilation aborted for /usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg/mpegfile.cpp (code 2)

0 Kudos
5 Replies
SergeyKostrov
Valued Contributor II
140 Views

Hi, >>... >>/usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.tcc(66): error #308: class template "TagLib::List::ListPrivate >>[with T=TagLib::ByteVector]" (declared at line 245 of "/usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.h") is inaccessible >>template class List::ListPrivate : public ListPrivateBase >>... ... #ifndef DO_NOT_DOCUMENT template class ListPrivate; ListPrivate *d; #endif ... Did you try to UNdefine 'DO_NOT_DOCUMENT' macro at the beginning of 'tlist.h' file, like '#undef DO_NOT_DOCUMENT'? >>...Is there an icpc option that will fix this... It looks like a declaration error and C++ compilers do not fix or workaround such problems. Best regards, Sergey
albl500
Beginner
140 Views

Sergey Kostrov wrote:

Did you try to UNdefine 'DO_NOT_DOCUMENT' macro at the beginning of 'tlist.h' file, like '#undef DO_NOT_DOCUMENT'?

I have now. Same error. Good spot though. I then thought to try `grep -r 'DO_NOT_DOCUMENT' ./`, to see where else it might be defined. Other than in preprocessor macros (e.g. `#ifndef DO_NOT_DOCUMENT`), I only see it in Doxyfile and Doxyfile.cmake, as a variable in `PREDEFINED`. I thought that might translate as a preprocessor definition somewhere, but deleting it made no difference to the comilation error.
Sergey Kostrov wrote:

>>...Is there an icpc option that will fix this...

It looks like a declaration error and C++ compilers do not fix or workaround such problems.

Okay. So I changed the declaration for the one you wrote above, and a slew of other errors pop up as a result, most notable of which is probably the first:- [bash] /usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.h(246): error: explicit instantiation is not allowed in the current scope template class ListPrivate; ^ /usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.h(247): error: identifier "ListPrivate" is undefined ListPrivate *d; ^ /usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.tcc(69): error #303: explicit type is missing ("int" assumed) ListPrivate() : ListPrivateBase() {} ^ /usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.tcc(69): error: expected a ";" ListPrivate() : ListPrivateBase() {} ^ /usr/local/src/AV/vlc/contrib/build/taglib/taglib/toolkit/tlist.tcc(82): warning #12: parsing restarts here after previous syntax error std::list list; ^ /usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg/id3v1/id3v1tag.h(62): warning #161: unrecognized #pragma TAGLIB_IGNORE_MISSING_DESTRUCTOR ^ [/bash] compilation aborted for /usr/local/src/AV/vlc/contrib/build/taglib/taglib/mpeg/mpegfile.cpp (code 2) Thanks for looking into this. I've only just started learning C++ really; picked up my book again only yesterday after about a year or two of negligence. I'm about 100 pages away from templates, and there's only about 5 pages written about them, so the chances of me fixing this alone are basically nil... Cheers, Alex
SergeyKostrov
Valued Contributor II
140 Views

Could you try to change 'private' to 'public' as well? ... public: #undef DO_NOT_DOCUMENT #ifndef DO_NOT_DOCUMENT template class ListPrivate; ListPrivate *d; #endif ...
albl500
Beginner
140 Views

Hi Sergey, Moving the template definition into the public method section appears to fix the issue. However, using your changes to the declaration does not work; I get practically the same errors as in my last post. So, this appears to work:- [cpp] public: .... template <class TP> class ListPrivate; ListPrivate<T> *d; [/cpp] Thanks for helping me find a working fix. Cheers, Alex
SergeyKostrov
Valued Contributor II
140 Views

>>...Moving the template definition into the public method section appears to fix the issue. However, using your changes to the declaration >>does not work... Actually, I'm not surprised that attempt to undefine 'DO_NOT_DOCUMENT' failed. It was impossible to see all dependencies without installing a complete set of sources.
Reply