This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more infromation.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
I have an Hitachi HS7709 eval board that I am trying to get up and running on. I am having problems with the sprintf function. sprintf seems to work unless I use a floating point parameter, i.e. "sprintf(ca, "%f", a);" where ca is a 32 byte character array and a is a double. I am using newlib 1.8.1, gcc 2.95.2, binutils-2.9.1. If I run the program under the debugger, I can see that the floating point math is working correctly but after the sprintf function, nothing has been done to the target char array. If I change the format string to "%d" and use an integer param instead, it works fine. I have attached the code for a small test program below. I know it is not the most efficient code but we are trying to put together a benchmark for floating point performance. my_putchar is just the putchar routine from the docs for the eval board. Does anyone have any suggestions? Thanks, Steve ================= #include <stdlib.h> #include <stdio.h> #include <math.h> #include "fsrentry.h" void sendstr(const char *cp); int main() { double a = 0.0; char ca[32]; while(a <= 2.0*M_PI) { a += M_PI/8.0; sprintf(ca, "%e", a); sendstr(ca); } return 0; } void sendstr(const char *cp) { while(*cp) my_putchar(*cp++); } =============== # My Makefile. I have tried compiling with and without -mhitachi NAME = examples CC = sh-rtems-hms-gcc CXX = sh-rtems-hms-g++ AS = sh-rtems-hms-as LINKER_SCRIPT = sh.ld CFLAGS = -m3 -gstabs -O4 -mhitachi LDFLAGS = -mhitachi -m3 -gstabs -T$(LINKER_SCRIPT) -Wl,-Map=$(basename $@).map \ -L/home/steveg/bin/crossgcc/sh-rtems-hms/sh-rtems-hms/lib/m2 -lm all: sertest.txt sertest.txt: sertest.x sh-rtems-hms-objcopy -O srec sertest.x sertest.txt sertest.o: sertest.c $(CC) $(CFLAGS) -Wall $< -c -o $@ fsrjump.o: fsrjump.s $(AS) -g $< -o $@ sertest.x: sertest.o fsrjump.o $(CC) $(LDFLAGS) -o $@ $? # This clean rule can only be used with a properly setup Cygwin environment # or Linux. Sorry. .PHONY : clean clean: rm -f *.x *.o *.map core *.d .PHONY : distclean distclean: rm -f *.x *.o *.map core *.d *.\$$\$$\$$ *.d@ ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |