Dear CygWin users & developers!

Please, give me a hint, how to deal with the following problem
correctly. I have some code, that calls GraphicsMagick function and I
want to catch the exception thrown. Unfortunately, this does not happen,
when I compile the code with CygWin:

C:\test\bugs\cygwin_exception_test> cygwin_exception_test.exe
terminate called after throwing an instance of 'Magick::ErrorFileOpen'
  what():  Magick: Unable to open file (aaaa) reported by
/pub/cygports/graphicksmagick/GraphicsMagick-1.3.7-2/src/GraphicsMagick-1.3.7/magick/constitute.c:8268
(ReadImage)
      1 [sig] cygwin_exception_test 9488 open_stackdumpfile: Dumping
stack trace to cygwin_exception_test.exe.stackdump

For Debian it works as expected:

r...@debian:~/test/bugs/cygwin_exception_test# ./cygwin_exception_test
Cannot open file 'aaaa'

Or is it a GCC-specific problem? Any workarounds?

Additional information:
* Cygwin setup v2.697, gcc-g++-3.4.4-999, libGraphicsMagick3-1.3.7-2
* Debian squeeze, gcc-4.4.4-5, libgraphicsmagick++3-1.3.12-1

-- 
With best regards,
Dmitry
CXX             := g++
LD              := g++
RM              := /bin/rm

CXXFLAGS        := -g3 -O2
CPPFLAGS        := -I/usr/include/GraphicsMagick
LDFLAGS         := -L/usr/lib -L/usr/lib/X11

LIBS            := -lGraphicsMagick++ 

.PHONY: all

.SUFFIXES: .c .cpp

OBJ             = cygwin_exception_test.o

all: cygwin_exception_test

cygwin_exception_test: $(OBJ)
        $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)

clean:
        $(RM) -f *.o cygwin_exception_test
#include <Magick++.h>

#include <string>
#include <iostream>

using namespace std;

int main(int argc, char **argv) {
        string fileName = "aaaa";
        string type;

        Magick::InitializeMagick(*argv);

        try {
                Magick::Image image;
                image.ping(fileName);
                type = image.magick();
        } catch (...) {
                cerr << "Cannot open file '" << fileName << "'" << endl;
                exit(1);
        }

        cerr << "File type is '" << type << "'" << endl;

        return 0;
}

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to