casting on 64/32-bit environment
Mitja Ursic
mitja.ursic@email.si
Mon Oct 22 07:50:00 GMT 2007
On Fri, 12 Oct 2007 at 15:46:14, Andrew Haley wrote:
> The problem here is that we don't know what you don't understand.
>
> If you're casting a pointer to an (32-bit) int, then if you are on a
> 64-bit system, there will be overflow and some information will be
> lost. If you're on a 32-bit system then there won't be a problem.
> This seems obvious: what's the problem?
>
> Andrew.
Sorry for very late replay. My OS is 64 bit (Linux Red Hat 4 WS, Update 4, 64-
bit). I want to compile a program in 64-bit environment but due to casting I
don't trust to the compiled program. So I want to figure out which steps are
necessary to take and than to compiled program on 64-bit without casting
warnings. So if you have any advice what to do I would be happy. Perhapse a
part of a code would help to figure out what is the cause of my problems.
So, this is my casting warning:
func.cc: In function `void func()': func.cc:105: warning: cast to pointer from
integer of different size
PtrF.h: In constructor `PtrF<Element>::PtrF(Element*) [with Element = el]':
func.cc:105: instantiated from here PtrF.h:39: warning: cast from pointer to
integer of different size
Down I give a part of a code:
//FUNC.CC
void func ()
{
…
int iel=0;
…
PtrF <EL> el01 = (EL*) iel; //line 105
…
}
//PTRF.H
template <class Element>
class PtrF : public PtrC<Element>
{
public:
…
//constructor at line 39
PtrF(Element* ele):Ptr<Element>(ele),_vide((int)ele) {}
…
private :
int _vide;
};
//CLASS PTR
template <class Element>
class Ptr : public Obj
{
public:
…
//constructor
Ptr(Element *pointerEl = 0):_impP(new ImpP<Element>(pointerEl)){}
…
protected:
ImpP<Element> *_impP;
};
//CLASS IMPP
template <class Element> class ImpP
{
…
private:
Element* _ptr;
…
//constructor
ImpP(Element * element = 0):_ptr(element) {}
} ;
//EL CLASS
class EL : public Obj
{
…
public :
// constructor
EL(int vi,int vj, int vk):i(vi),j(vj),k(vk) {}
…
int i,j,k;
…
};
Mitja
____________________
http://www.email.si/
More information about the Gcc-help
mailing list