Web lists-archives.com

Re: [Mingw-users] Using mingw's libpng?




> Date: Wed, 06 Jul 2016 10:06:31 -0700
> From: mathog <mathog@xxxxxxxxxxx>
> Cc: mingw-users@xxxxxxxxxxxxxxxxxxxxx
> 
> The code in this tells libpng where to write the file in the usual
> manner:
> 
>           FILE *fp = fopen("filename","wb");
>           png_init_io(png_ptr, fp);

So this opens a file in the Python DLL, and then passes the FILE
pointer to the libpng DLL to use.  That's exactly what should not be
done.

> Which does make one wonder how this code ever works on any platform

Because the code is careless, and was probably only tested on a single
OS, where there's only one standard C library.  On Windows, there are
at least a dozen of different versions of C runtime, and Python
specifically is built with MSVC, so almost certainly uses a runtime
different from the MinGW default (which is msvcrt.dll).

> or why libpng does not come with a
> 
>          png_init_io_by_filename()
> 
> to avoid this problem.

Someone should suggest that to them.

But the real problem is in the Python module, they do something that
is extremely unportable.

> On linux setup.py builds the expected _cmd.so, also a shared
> library, and it uses exactly the same code, and this section of code
> works without a hiccup there.

On GNU/Linux, _cmd.so will be linked against the same libc.so as the
main program and libpng, so the problem is never seen.  Like I said:
unportable code.

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe