When trying to compile code for the PIC16F864 on a
debian x86_64 host, I get
sdcc: gen.c:9359: bitpatternFromVal: Assertion `sizeof
(float) == sizeof (long)' failed.
A quick look to the corresponding line in the source
code reveals that it makes the illegal assumption that
float and long have the same storage size.
My email: laforge@gnumonks.org
Logged In: YES
user_id=1115835
Hmm..., what's the `correct' way to do cast the bitpattern
of a float into a long?
float f;
long l = *(long *)(&f);
---
float f;
long l = 0;
memcpy(&l, &f, sizeof( float ) );
---
have two unions, one { double; long } and the other { float,
long } and select the correct one based on sizeof( double )
== sizeof( long ) vs. sizeof( float ) == sizeof( long ), and
emit an error if neither holds?
Can you verify the result is correct if the assertion is
simply removed? I cannot due to lack of x86_64 machines ;-)
Regards,
Raphael
Logged In: YES
user_id=888171
I'd recommend to include stdint.h and use uint32_t instead
of unsigned long.
Logged In: YES
user_id=1115835
Fixed using Maarten's hint in SDCC r4182.
Logged In: YES
user_id=888171
Ok, so I cut myself here. Visual C, which I happen to use,
does not have the stdint.h header file. Not for VC6 nor
VC7 nor VC8. Luckily someone already implemented a small
open source version of it:
http://www.quantum-leaps.com/downloads/ports.htm#QEP
There are probably more out there.
Logged In: YES
user_id=203539
The "official" target-types are:
"TYPE_WORD", "TYPE_UWORD", "TYPE_DWORD" and "TYPE_UDWORD" for
"int", "unsigned int", "long" and "unsigned long". See
"specifier" in SDCCsymt.h
These types are evaluated by 'configure' and stored in
sdccconf.h (there's a sdcc_vc_in.h for VC).
May be aopLiteral() or aopLiteralLong() in SDCCglue.c is
doning what you're looking for.
HTH!
Logged In: YES
user_id=888171
Raphael,
Bernhard is right. Why don't you use aopLiteral()?
Please have a look at the attached patch.
Maarten
Remove bitpatternFromVal, use aopLiteral