#111 need help resolving assert conflict

1.3.0
closed
nobody
None
5
2015-10-04
2009-08-28
No

I have sat down to explore using the FLAC++ library in Rosegarden ( https://sourceforge.net/projects/rosegarden/ ).

After tweaking the build system to pick up this library, a sample build line for one of our sources becomes:

g++ -c -g3 -O2 -gstabs+3 -Wfatal-errors -DNDEBUG -DBUILD_RELEASE -DNO_TIMING -g0 -O2 -Wall -pipe -DHAVE_LIRC -DHAVE_LIBJACK -DHAVE_ALSA -I/usr/include/qt4/Qt3Support -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXml -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtCore -I/usr/include/qt4 -DQT3_SUPPORT -I/usr/include/alsa -I/usr/include/FLAC++ -I/usr/include/FLAC -DLITTLE_ENDIAN=1 -D'VERSION="10.02"' -D'CODENAME="Thorn"' -Isrc -D'BUILDKEY="09e8c70e47"' src/base/Composition.cpp -o src/base/Composition.o

(I've included the whole thing in case there is anything I'm not seeing that's of interest beyond the obvious -I/usr/include/FLAC++ -I/usr/include/FLAC)

OK then, the problem is we #include <cassert> and use assert() all over the place, and in the first such file:

...
#include <cassert>
...
assert(m_v == i.m_v);

The build now fails with a new and mysterious error:

src/base/FastVector.h: In member function ‘T& FastVector<T>::at(long int)’:
src/base/FastVector.h:286: error: there are no arguments to ‘assert’ that depend on a template parameter, so a declaration of ‘assert’ must be available
compilation terminated due to -Wfatal-errors.

This error is a direct consequence of adding -I/usr/include/FLAC++ -I/usr/include/FLAC, and it seems to be because FLAC++ (and/or FLAC) has its own definition of assert that's conflicting with the standard definition in <cassert> but that is as far as I have been able to puzzle this out. Google doesn't have much to say about this kind of problem, and none of the apparently stupid things I tried to work around this had any effect.

I feel like a moron for not being able to work this out on my own, but I really don't know what to do here, and as it stands now, I'm not going to be able to use this library after all.

Have you guys seen this before in applications that tried to use your library? Any suggestions how to resolve this conflict?

Discussion

  • lvqcl

    lvqcl - 2015-06-19

    (just stumbled upon this ticket)

    This error is a direct consequence of adding -I/usr/include/FLAC++ -I/usr/include/FLAC

    Yes.

    and it seems to be because FLAC++ (and/or FLAC) has its own definition
    of assert that's conflicting with the standard definition in <cassert>

    No, but libFLAC has its own assert.h that can conflict with the system assert.h.

     
  • Erik

    Erik - 2015-06-19

    The solution is to do is to replace "#include <flac.h>" with"#include <FLAC/flac.h>" and then replacing "-I/usr/include/FLAC" on the gcc comand line with "-I/usr/include".

     
  • Erik

    Erik - 2015-10-04
    • status: open --> closed
    • Group: --> 1.3.0
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks