Page 1 of 1

Different results for same code

Posted: 2014-05-08T10:10:06-07:00
by kirash4
I'm scratching my head and wondering if anyone here might have an idea as to what's going on. I have the following snippet:

Code: Select all

#include <Magick++.h>
#include <iostream>

int main(int argc, char *argv[]) {
  static char const *filename = argv[1];
  try {
    Magick::Image originalImage(filename);
  catch (Magick::Exception & error) {
    std::cerr << "Caught exception: " << error.what() << std::endl;
  return 0;
When I compile that on a unix server then try to feed it an invalid image format, it will return an exception telling me there's no decode delegate for that, as I would expect it would. However, when I compile this same exact snippet on my Cygwin environment, I get nothing back, or rather, what appears to be a blank line:

On unix:
> ./test test.cpp
Caught exception: test: no decode delegate for this image format `test.cpp' @ error/constitute.c/ReadImage/501
On Cygwin:
> ./test test.cpp

Or if I use the full file name on Cygwin:
> ./text.exe text.cpp

Note that there is an empty line on the Cygwin output, which makes me think it is outputting something, or at least trying to. So why am I not getting the exception notice on Cygwin? It doesn't matter if I use std::cerr or std::cout for that matter.