You can't cast a pointer to an integer; that's what uintptr_t is for.

dm...@angus> cat -n testptr.c
      1  #include <inttypes.h>
      2
      3  void
      4  f(void)
      5  {
      6          char *p;
      7          unsigned int i;
      8
      9          i = p;
     10          i = (uintptr_t)p;
     11  }
     12
dm...@angus> cc -c testptr.c
"testptr.c", line 9: warning: improper pointer/integer combination: op "="

Jin wrote:
> Hi, 
> 
>     I add some test codes to ../uts/common/os/kcpc.c. 
> 
> int
> kcpc_bind_thread(kcpc_set_t *set, kthread_t *t, int *subcode)
> {
>     ......
>     /* new codes. */
>     cmn_err(CE_NOTE, "ks_data = %" PRId64 ".\n", (uint64_t)set->ks_data);
>     ......
> }
> 
> The compiler says "warning: cast from pointer to integer of different size". 
> The warning makes the compiling process returns with error. 
> The based kernel source is snv_107 and running platform is also snv_107. 
> The set->ks_data is one pointer, I want to print it's address out. 
> 
> struct _kcpc_set {
>                 ......
>       uint64_t                *ks_data;       /* Data store for this set */
> }; 
> 
> I don't think the case is one error. Can you give some suggestions?
> thanks

_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to