How do I work around the GCC “error: cast from ‘SourceLocation*’ to ‘int’ loses precision” error when compiling cmockery.c?

339 views
Skip to first unread message

Daryl Spitzer

unread,
Jan 3, 2011, 12:50:34 PM1/3/11
to Cmockery
I posted this question in detail at
http://stackoverflow.com/questions/4586808/how-do-i-work-around-the-gcc-error-cast-from-sourcelocation-to-int-loses-p.
But here's a summary to spare you the trouble of reading all the
detail (unless you think you can help):

I need to add unit tests using Cmockery to an existing build
environment that uses as hand-crafted Makefile. So I need to figure
out how to build cmockery.c (without automake). But when I compile
cmockery.c, I get a long list of errors like:

../cmockery-0.1.2/cmockery.c: In function ‘void
initialize_source_location(SourceLocation*)’:
../cmockery-0.1.2/cmockery.c:248: error: cast from ‘SourceLocation*’
to ‘int’ loses precision

I (of course) don't get these errors when I build cmockery-0.1.2 using
`./configure` and `make`.

How do I work around these errors?

--
Daryl Spitzer

Andreas Schneider

unread,
Jan 3, 2011, 1:07:19 PM1/3/11
to cmoc...@googlegroups.com

Looks like you're project is using some compiler options to turn this warning
into an error. This should be patched and a patch for this has been posted
some time ago.

I'm currently trying to figure out is there is still a developer or
maintainer. If not I would like to do that in future.

Cheers,


-- andreas

Steve Byan

unread,
Jan 3, 2011, 1:15:26 PM1/3/11
to cmoc...@googlegroups.com

Are you compiling for a 64-bit platform? Looks like it to me based on the error message.

cmockery doesn't support 64-bit platforms without gcc warnings, and I think it doesn't functionally support either LP64 or LLP64 (I forget which).

We have a reworked version that is 64-bit clean, but we haven't released it yet. Unfortunately it requires some changes to the cmockery API.

Best regards,
-Steve

--
Steve Byan <stev...@me.com>
Littleton, MA 01460

Daryl Spitzer

unread,
Jan 3, 2011, 1:45:23 PM1/3/11
to cmoc...@googlegroups.com
> Are you compiling for a 64-bit platform? Looks like it to me based
> on the error message.

Yes.  Switching to gcc (from g++) and adding "-m32" did the trick.

> We have a reworked version that is 64-bit clean, but we haven't
> released it yet.

I look forward to the release.

> Unfortunately it requires some changes to the cmockery API.

Is that what is holding up the release?

Thanks Steve.

--
Daryl





--
You received this message because you are subscribed to the Google Groups "Cmockery" group.
To post to this group, send email to cmoc...@googlegroups.com.
To unsubscribe from this group, send email to cmockery+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cmockery?hl=en.


Steve Byan

unread,
Jan 3, 2011, 1:52:49 PM1/3/11
to cmoc...@googlegroups.com

On Jan 3, 2011, at 1:45 PM, Daryl Spitzer wrote:

> > Are you compiling for a 64-bit platform? Looks like it to me based
> > on the error message.
>
> Yes. Switching to gcc (from g++) and adding "-m32" did the trick.
>
> > We have a reworked version that is 64-bit clean, but we haven't
> > released it yet.
>
> I look forward to the release.
>
> > Unfortunately it requires some changes to the cmockery API.
>
> Is that what is holding up the release?

No, although that will probably hold up merging the code into cmockery mainline.

Mostly, I have yet invest the time to get formal approval from our legal department. I do have agreement in principle from my management to release the code. Partly, I haven't tested it on Windows yet (though it should work there).

I'll start the legal machinery in motion to get the code released.

Reply all
Reply to author
Forward
0 new messages