compilation wrning in altix350:(Typecasting from int to void *)

  • Thread starter ramakanta.sinha
  • Start date
R

ramakanta.sinha

Hi,

While typecasting an integer to (void *) the following warning
is found.

warning: cast to pointer from integer of different size.

This is the line where typecasting is done.
fld->base = (void *)(((fld->f90_table_index-1) *
F90_MAX_FLD_SIZE_IN_BYT
ES + 1 ));

fld->base is of type (void *)
((fld->f90_table_index-1) * F90_MAX_FLD_SIZE_IN_BYTES + 1 ) is an
integer.

This is a c++ code, compiled using c++ compiler in altix350.


Waiting for immediate help to resolve the warning.

Thanks in advance,
Rama Kanta Sinha.
 
R

Rolf Magnus

Hi,

While typecasting an integer to (void *) the following warning
is found.

Why do you cast an integer to a pointer?
warning: cast to pointer from integer of different size.

This is the line where typecasting is done.
fld->base = (void *)(((fld->f90_table_index-1) *
F90_MAX_FLD_SIZE_IN_BYT
ES + 1 ));

fld->base is of type (void *)
((fld->f90_table_index-1) * F90_MAX_FLD_SIZE_IN_BYTES + 1 ) is an
integer.

This is a c++ code, compiled using c++ compiler in altix350.


Waiting for immediate help to resolve the warning.

Well, don't cast an integer to a pointer or use an integer type that has the
same size as a pointer on your architecture. Your compiler's manual should
tell you the sizes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top