David C. Rankin wrote:
Anders Johansson wrote:
On Sunday 04 May 2008 03:19:29 David C. Rankin wrote:
Listmates, [...] The code compiles without error or warning with: "gcc -o prg/tmp src/tmp.c" Here is the bewildering output:
Well, no it doesn't. It says "implicit declaration of stdtof"
If you read the man page for strtof it says
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
strtof(), strtold(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or cc -std=c99
So try
gcc -std=c99 -o prg/tmp src/tmp.c
Without that -std=c99, gcc simply doesn't know what strtof() is, and calls it incorrectly (it assumes it accepts an int as parameter and returns an integer, and generates assembly accordingly. You're unlucky you got bad data - the 'good' return value would have been a seg fault)
Anders
Don't be so sure, I got a number of seg faults too ;-) Thanks. Now it makes sense. I read the man page 5 times over, but the -std=c99 never sank in. Googling gave hints in the discussions regarding GNU c, ASNI C and the c99 variant. The last time I was current and fluent with Fortan, C/C++ on both unix on Sun SPARC servers and Borland on (God forbid DOS 3.3) was 1995 when I left NASA in Houston to try the legal profession. (May 8, 1995 to be exact) It is amazing how much has changed and equally amazing how much has stayed the same in the past 13 years. Thanks for your continued help as I try and reconnect synapses and add a few new tools along the way.
I know how you feel. I'm finally getting around to learning C++ (solely because I believe that C++ + Qt is the best development environment for turning a series of rather complex boards game into a computer game). The last time I did any serious programming (other than writing shell scripts), ANSI C was still brand new. The K&R C book was still the standard reference & textbook. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org