Why does compiling Mongoose on OSX 64 bit generate so many warnings?

195 views
Skip to first unread message

Andrew Wulf

unread,
Nov 27, 2013, 11:18:06 PM11/27/13
to mongoos...@googlegroups.com
Using XCode with Clang 5.0 and x86_64 I get a ton of value conversion issues. It still seems to work, at least the basic example does.

I need 64bit since I am using a Foundation app with arc which only supports x86_64.

Sergey Lyubka

unread,
Nov 28, 2013, 3:26:11 AM11/28/13
to mongoose-users
Maybe you're compiling as C++ instead of C?
Showing an example snippet would help anyway.


On Thu, Nov 28, 2013 at 4:18 AM, Andrew Wulf <ahw...@gmail.com> wrote:
Using XCode with Clang 5.0 and x86_64 I get a ton of value conversion issues. It still seems to work, at least the basic example does.

I need 64bit since I am using a Foundation app with arc which only supports x86_64.

--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.

Andrew Wulf

unread,
Nov 28, 2013, 9:04:01 AM11/28/13
to mongoos...@googlegroups.com
Compiling as Objective-C, although I tried pure c++ earlier and got the same errors in 64bit.

All 28 errors are the same, having to do with losing integer precision

mongoose.c:488:66: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'socklen_t' (aka 'unsigned int')
mongoose.c:543:20: Implicit conversion loses integer precision: 'unsigned long' to 'int'
mongoose.c:543:49: Implicit conversion loses integer precision: 'unsigned long' to 'int'
mongoose.c:705:40: Implicit conversion loses integer precision: 'long' to 'int'
mongoose.c:707:54: Implicit conversion loses integer precision: 'long' to 'int'
mongoose.c:859:19: Implicit conversion loses integer precision: 'long' to 'int'
mongoose.c:904:32: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:904:54: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:2053:31: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:2522:35: Implicit conversion loses integer precision: 'unsigned long' to 'int'
mongoose.c:2523:45: Implicit conversion loses integer precision: 'unsigned long' to 'int'
mongoose.c:2704:13: Implicit conversion loses integer precision: 'long' to 'int'
mongoose.c:2862:13: Implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int'
mongoose.c:2884:13: Implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int'
mongoose.c:2890:13: Implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int'
mongoose.c:3003:21: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:3008:44: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:3371:36: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:3434:18: Implicit conversion loses integer precision: 'unsigned long' to 'int'
mongoose.c:4048:44: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:4080:24: Implicit conversion loses integer precision: 'unsigned long' to 'int'
mongoose.c:4375:22: Implicit conversion loses integer precision: 'unsigned long' to 'int'
mongoose.c:4419:36: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:4444:29: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:4451:29: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:4459:25: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
mongoose.c:4626:27: Implicit conversion loses integer precision: 'unsigned long' to 'int'
mongoose.c:4638:27: Implicit conversion loses integer precision: 'unsigned long' to 'int'

jeff shanab

unread,
Nov 28, 2013, 9:21:00 AM11/28/13
to mongoos...@googlegroups.com
These are usually warnings not errors but should be fixed.
Usually there is a bit of an ifdef based on a sizeof operator that then defines/redefines.

size_t is 32 bit on 32 bit systems and 64bit on 64 bit systems.
Either add casts if the source value is indeed 32 bit, like if it comes from javascript
or change the code to use a defined type. ie uint64_t
This is sometimes best handled by a project wide define or just use size_t instead of unsigned long and it will always be right.

But watch out. a few other things need to be taken care of, like atoi there is a 32 and a 64 bit version.
I have seen little 32/64 shim headers in most projects, Look at curl, POCO, boost

 

Sergey Lyubka

unread,
Dec 3, 2013, 3:12:46 PM12/3/13
to mongoose-users
Note that mongoose is C, not C++ and not Objective C.
I am using both 32 and 64 bit platforms for development, actually
my main platform is MacOS, x86_64, with pretty new clang compiler
(Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)),and it
doesn't give me a single warning.

Please compile mongoose as C, and let me know of any warning/errors.
And thanks for reporting that.

Reply all
Reply to author
Forward
0 new messages