Pelles C forum

Pelles C => Bug reports => Topic started by: akko on April 21, 2007, 02:33:33 PM

Title: How to ecvt?
Post by: akko on April 21, 2007, 02:33:33 PM
Sadly, ecvt does not work, despite it is declared in the msvcrt.lib of PellesC.

There is a small thread in the "experts" section of the forum, concerning some remedy actions. However none of ideas expressed there are working.

The following proggie works with all different C compilers on my computer,  but not with PellesC:

/* Cheap ecvt test */
#include <stdio.h>
#include <stdlib.h>
void main(void)
{  int a, b;
   char * conv = ecvt(9e0,20,&a,&b);
   printf("\nECVT Test: %f -> %s, %d, %d ",9e0,conv,a,b);
}

It should print:
ECVT Test: 9.000000 -> 90000000000000000000, 1, 0
Title: Re: How to ecvt?
Post by: TimoVJL on April 21, 2007, 03:45:00 PM
Missing function prototype.

http://msdn2.microsoft.com/en-us/library/z4s4541k(VS.80).aspx

Code: [Select]
/* Cheap ecvt test */
#include <stdio.h>
#include <stdlib.h>

char *_ecvt(double value, int ndigit, int *decpt, int *sign);
#pragma lib "msvcrt.lib"

void main(void)
{  int a, b;
   char * conv = _ecvt(9e0,20,&a,&b);
   printf("\nECVT Test: %f -> %s, %d, %d\n",9e0,conv,a,b);
}

/*
It should print:
ECVT Test: 9.000000 -> 90000000000000000000, 1, 0
*/
Title: Re: How to ecvt?
Post by: Pelle on April 21, 2007, 04:47:07 PM
ecvt is not part of standard C, and Posix flag it as 'legacy' (The sprintf() function is preferred over ecvt, fcvt, gcvt). I see no reason in the world to support it...
Title: Re: How to ecvt?
Post by: akko on April 22, 2007, 09:29:36 PM
Thanks Timo, that works.
However I get the warning
POLINK: warning: Multiple '.rdata' sections found with different flags (0x40000040 and 0xc0000040).

Pelle:
Of course everything is up to you. However please think of those who want to use good valid legacy code.
And it is NOT trivial to express ecvt by snprintf.
IMHO ony should be able to use all routines in msvcrt.lib. They come for free, don't they?
You are already supporting io.h which contains mostly POSIX and not C99 definitions.