Witam
Mam problem z konwersją flota w printf/sprintf. W miejscu gdzie powinien być wynik konwersji, printf wstawia "ERROR". Biblioteka libm jest niby dołączona (-lm), ale to nic nie daje. Co powinno być jeszcze wstawione w opcjach żeby zaczęło to działać, a może to z innego powodu nie działa? Może malloc nie che przydzielić pamięci dla printfa? Tu jeszcze mam prośbę o kod sprawdzonej funkcji _sbrk_r, może w tej co ja mam jest coś nie tak, ale z drugiej strony nic w niej takiego nie ma.
Mam problem z konwersją flota w printf/sprintf. W miejscu gdzie powinien być wynik konwersji, printf wstawia "ERROR". Biblioteka libm jest niby dołączona (-lm), ale to nic nie daje. Co powinno być jeszcze wstawione w opcjach żeby zaczęło to działać, a może to z innego powodu nie działa? Może malloc nie che przydzielić pamięci dla printfa? Tu jeszcze mam prośbę o kod sprawdzonej funkcji _sbrk_r, może w tej co ja mam jest coś nie tak, ale z drugiej strony nic w niej takiego nie ma.
Code:
/* "malloc clue function" */
/**** Locally used variables. ****/
extern char _ebss[]; /* end is set in the linker command */
/* file and is the end of statically */
/* allocated data (thus start of heap). */
static char *heap_ptr; /* Points to current end of the heap. */
/************************** _sbrk_r *************************************/
/* Support function. Adjusts end of heap to provide more memory to */
/* memory allocator. Simple and dumb with no sanity checks. */
/* struct _reent *r -- re-entrancy structure, used by newlib to */
/* support multiple threads of operation. */
/* ptrdiff_t nbytes -- number of bytes to add. */
/* Returns pointer to start of new heap area. */
/* Note: This implementation is not thread safe (despite taking a */
/* _reent structure as a parameter). */
/* Since _s_r is not used in the current implementation, the following */
/* messages must be suppressed. */
void * _sbrk_r(
struct _reent *_s_r,
ptrdiff_t nbytes)
{
char *base; /* errno should be set to ENOMEM on error */
if (!heap_ptr) { /* Initialize if first time through. */
heap_ptr = _ebss;
}
base = heap_ptr; /* Point to end of heap. */
heap_ptr += nbytes; /* Increase heap. */
return base; /* Return pointer to start of new heap area. */
}