I\'ve made two functions to \'cast\' a 32/64 bit pointer into a double. The code worked when used alone (Just the .h and a .cpp including it) but when using the .h somewhere
The canonical way to would be:
#pragma once
#ifndef __FLOATCAST_H
#define __FLOATCAST_H
//A quick and dirty way of casting pointers into doubles and back
//Should work with BOTH 64bit and 32bit pointers
union ptr_u {
double d;
void* p;
};
double ptr2double(void* pv);
void* double2ptr(double dv);
#endif
#include "floatcast.h"
double ptr2double(void* pv){
ptr_u ptr;
ptr.p = pv;
return (ptr.d);
};
void* double2ptr(double dv){
ptr_u ptr;
ptr.d = dv;
return(ptr.p);
};