On Solaris10/Sparc, I also get this:
CC code/sys/sys_unix.c
CC code/client/libmumblelink.c
code/client/libmumblelink.c: In function `mumble_link':
code/client/libmumblelink.c:88: warning: int format, uid_t arg (arg 4)
code/client/libmumblelink.c:89: warning: implicit declaration of function `shm_open'
code/client/libmumblelink.c: In function `mumble_unlink':
code/client/libmumblelink.c:126: warning: passing arg 1 of `munmap' from incompatible pointer type
CC code/sdl/sdl_glimp.c
LD build/release-sunos-sparc/ioquake3.sparc
CGAME_CC code/cgame/cg_main.c
CGAME_CC code/game/bg_misc.c
CGAME_CC code/game/bg_pmove.c
Under Solaris, shm_open is defined as:
NAME
shm_open - open a shared memory object
SYNOPSIS
cc [ flag... ] file... -lrt [ library... ]
#include <sys/mman.h>
int shm_open(const char *name, int oflag, mode_t mode);
Tested it with the latest build on Solaris10/Sparc, I still get this:
gmake[2]: Entering directory `/net/thorbardin/export/home/raistlin/SVN/icculus/ioquake3-sunos/trunk'
gmake[2]: `build/release-sunos-sparc/ioq3ded.sparc' is up to date.
CC code/client/libmumblelink.c
code/client/libmumblelink.c: In function `mumble_link':
code/client/libmumblelink.c:88: warning: int format, uid_t arg (arg 4)
code/client/libmumblelink.c:89: warning: implicit declaration of function `shm_open'
code/client/libmumblelink.c: In function `mumble_unlink':
code/client/libmumblelink.c:126: warning: passing arg 1 of `munmap' from incompatible pointer type
I'm still investiguating...
Here's an excerpt from Solaris sys/mman.h:
#ifdef __STDC__
#if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
extern void *mmap(void *, size_t, int, int, int, off_t);
extern int munmap(void *, size_t);
extern int mprotect(void *, size_t, int);
extern int msync(void *, size_t, int);
#if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
extern int mlock(const void *, size_t);
extern int munlock(const void *, size_t);
extern int shm_open(const char *, int, mode_t);
extern int shm_unlink(const char *);
#endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */
I wonder if this has to do with any of these flags.. (In that case that'd be a Solaris bundled compiler issue).
I found a related discussion on this:
http://bugs.mysql.com/bug.php?id=7156
It's related to madvise but it shows that something is 'different' with the Solaris headers, thereby causing the problem...
(In reply to comment #6)
> I wonder if instead of:
> munmap(lm, sizeof(LinkedMem));
> we shouldn't be using:
> munmap((void *)lm, sizeof(LinkedMem));
A function that takes a (void*) shouldn't need to explicitly cast a non-void pointer to (void*).
But if it makes the compiler warning go away, I'll take it. :)
--ryan.
Well, I thought the implicit warning related to shm_open() whereas the incompatible pointer type related to munmap()..
Strangely enough munmap() and shm_open() are located (under Solaris) in the same header file (/usr/include/sys/mman.h) but not within the same #ifdef's...:
#if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
extern void *mmap(void *, size_t, int, int, int, off_t);
extern int munmap(void *, size_t);
extern int mprotect(void *, size_t, int);
extern int msync(void *, size_t, int);
#if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
extern int mlock(const void *, size_t);
extern int munlock(const void *, size_t);
extern int shm_open(const char *, int, mode_t);
extern int shm_unlink(const char *);
#endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */
So if we do...
#define _POSIX_C_SOURCE 2
...before including the header, does the problem go away?
(and if it does, is that the wrong way to fix this?)
--ryan.
Hi Ryan,
#define _POSIX_C_SOURCE 2
doesn't fix it but fhe following does
#define _POSIX_C_SOURCE 199309L
I tried to investiguate the problem further but I was unable to figure out how other big projects did it to avoid the warning. I found some info in a man page named 'standards' on Solaris (See http://compute.cnr.berkeley.edu/cgi-bin/man-cgi?standards)
With this diff, it compiles fine:
diff -c -r1.1 libmumblelink.c
*** libmumblelink.c 2009/09/17 08:25:48 1.1
--- libmumblelink.c 2009/09/17 09:28:00
***************
*** 25,30 ****
--- 25,33 ----
#define uint32_t UINT32
#else
#include <unistd.h>
+ #ifdef __sun
+ #define _POSIX_C_SOURCE 199309L
+ #endif
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
All that's left is a warning about the format absence of cast:
# make
gcc -Wall -c -o libmumblelink.o libmumblelink.c
libmumblelink.c: In function `mumble_link':
libmumblelink.c:91: warning: int format, uid_t arg (arg 4)
The POSIX standard requires applications to define _POSIX_C_SOURCE before including any POSIX headers to get function declarations, so it's not Solaris-specific ([1]). The reason why it went unnoticed is probably because of dependency library supplied CPPFLAGS (for example, sdl-config --cflags on GNU/Linux outputs -D_GNU_SOURCE, which in turn defines _POSIX_C_SOURCE).
Thus, ioquake3 source code on UNIX/POSIX platforms probably should define _POSIX_C_SOURCE to the oldest version that provides all necessary functions. Some possible values are "199309L", "199506L", "200112L" and "200809L".
[1] http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_02_01
On Solaris10/Sparc, I also get this: CC code/sys/sys_unix.c CC code/client/libmumblelink.c code/client/libmumblelink.c: In function `mumble_link': code/client/libmumblelink.c:88: warning: int format, uid_t arg (arg 4) code/client/libmumblelink.c:89: warning: implicit declaration of function `shm_open' code/client/libmumblelink.c: In function `mumble_unlink': code/client/libmumblelink.c:126: warning: passing arg 1 of `munmap' from incompatible pointer type CC code/sdl/sdl_glimp.c LD build/release-sunos-sparc/ioquake3.sparc CGAME_CC code/cgame/cg_main.c CGAME_CC code/game/bg_misc.c CGAME_CC code/game/bg_pmove.c Under Solaris, shm_open is defined as: NAME shm_open - open a shared memory object SYNOPSIS cc [ flag... ] file... -lrt [ library... ] #include <sys/mman.h> int shm_open(const char *name, int oflag, mode_t mode);