A program of mine "binload" which has key parts:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <float.h>
#include <stdint.h> /* for uint8_t */
#include <inttypes.h> /* for PRId64 */
#include <time.h>
#include <unistd.h> /* for close */
#include <errno.h>
int main(int argc,char **argv){
errno = 0; /* Works around an issue with OpenMPI preload which can
leaver errno set */
float fv;
char buffer[1024];
char *final;
/* code that reads a line of text and puts it into buffer */
fv = strtof(buffer,&final);
fprintf(stderr,"DEBUG buffer %p final %p fv %f errno
%d\n",buffer,final,fv, errno);fflush(stderr);
is compiled on mingw64 with:
gcc -o binload binload.c
When the strtof() function runs with buffer containing the string
"1.0e+40" it fails, as it should,
because the value is too large for a float. On linux errno is set and
later code handles the error. However in mingw64 that debug line emits:
DEBUG buffer 000000000068F970 final 000000000068F977 fv 1.#INF00 errno 0
Because errno is not set the error isn't handled correctly. If the
formatted float in "buffer" is
within range then strtof() returns the correct value. For instace, for
1.0e+04 it emits:
DEBUG buffer 000000000068F970 final 000000000068F977 fv 10000.000000
errno 0
Am I using errno improperly for mingw64 (maybe some Windows variant is
needed instead?) or is there some other issue in play?
Thanks,
David Mathog
mat...@caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public