[LLVMdev] Convert C++ to C. What is 0x0p+0 ?
Mohd-Hanafiah Abdullah
napi at axiomsol.com
Sun Nov 5 02:30:16 PST 2006
On Sat, 2006-11-04 at 21:06 -0800, Reid Spencer wrote:
> Hi Napi,
>
> On Sun, 2006-11-05 at 12:40 +0800, Mohd-Hanafiah Abdullah wrote:
> > Hi:
> >
> > I'm interested in using llvm to convert C++ code to C code.
> > I used the following command to do this:
> >
> > % llvm-g++ -c foo.cpp -o - | llc -march=c -o foo.cbe.c
>
> Yup, that'll do it. Although you might want to do a little optimization
> otherwise you're going to get a lot of C code on output. Try passing -O2
> to llvm-g++.
>
> > In the resulting file foo.cbe.c there are many occurences of '0x0p+0'.
> > What is it used for? Here's a code snippet from the file foo.cbe.c
> >
> > if ((ltmp_126_2 > 0x0p+0)) {
> > goto ltmp_363_19;
> > } else {
> > goto ltmp_364_19;
> > }
> >
> > llvm-gcc is able to compile foo.cbe.c, but I need to use another C
> > compiler which gives a syntax error message for not recognizing
> > the expression '0x0p+0'.
>
> Get a new C compiler :)
>
> The syntax in question is a C99 feature. It is printed by the C Backend
> with the %a conversion token for printf. This is the representation of a
> floating point number in hexadecimal. It allows certain values that
> cannot otherwise be represented with a decimal number to be represented.
> The C Backend needs to use this to ensure that the floating point value
> it has in mind is *exactly* represented through the conversion to the C
> source and then back by your C compiler.
Hi Reid:
Thank you for your email. I need to use this C compiler that only
supports ANSI C 1989. What is the equivalent of '0x0p+0' in C89 ?
Is there any way around this?
Thanks.
Napi
More information about the llvm-dev
mailing list