If I compile this with "g++ -o foo foo.cpp -ldjvulibre" and execute "./foo", I
get:
terminate called after throwing an instance of 'DJVU::GException'
Aborted
If I compile it with "g++ -o foo foo.cpp" and execute, then I get:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted
Merely linking libdjvulibre changes the behaviour of the code above (which is
independent of libdjvulibre). Can I somehow make libdjvulibre not bleed
outside its API?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Of course, doing that likely breaks error handling inside djvulibre.
IMO, djvulibre shouldn't make such a global modification. It seems
DJVU::GException is not part of the API (ddjvuapi.h, miniexp.h). Also, what
if another library I linked in did the same? Then one or the other would have
broken error handling. I guess there's no easy way to fix this, though. So
I'll just try not caring about mem alloc failures. :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm puzzled why the following code throws DJVU::GException instead of
std::bad_alloc.
If I compile this with "g++ -o foo foo.cpp -ldjvulibre" and execute "./foo", I
get:
If I compile it with "g++ -o foo foo.cpp" and execute, then I get:
Merely linking libdjvulibre changes the behaviour of the code above (which is
independent of libdjvulibre). Can I somehow make libdjvulibre not bleed
outside its API?
DjVu Libre overloads new.
Bill
Thanks, Bill. It appears to not actually overload, but modify the behaviour of
the standard new. From GException.cpp:
So if I compile and link the following with djvulibre, I get std::bad_alloc
back:
Of course, doing that likely breaks error handling inside djvulibre.
IMO, djvulibre shouldn't make such a global modification. It seems
DJVU::GException is not part of the API (ddjvuapi.h, miniexp.h). Also, what
if another library I linked in did the same? Then one or the other would have
broken error handling. I guess there's no easy way to fix this, though. So
I'll just try not caring about mem alloc failures. :)