M
m0shbear
I'm trying to use this code to check the compiler's output to see if
the inlining is aggressive enough to use inline functions instead of
#defines and I'm getting the following error: "invalid initialization
of reference of type ‘const unsigned char*&’ from expression of type
‘u8*’".
Does the inline lowercase match the macro uppercase?
code:
extern "C" {
#include <stdint.h>
}
typedef uint8_t u8;
typedef uint64_t u64be;
template <typename T>
struct itype {
typedef T value;
typedef T& reference;
typedef T const& const_reference;
typedef T* pointer;
typedef T const* const_pointer;
};
#define PTR_CAST(T, p) (reinterpret_cast<T*>(p))
#define XF64(dst,src) *PTR_CAST(u64be,dst) ^= *PTR_CAST(u64be
const,src); (src) += 8
template<typename T, typename P> inline T* ptr_cast(P* p) { return
reinterpret_cast<T*>(p); }
inline void xf64(itype<u8>:ointer dst,
itype<itype<u8>::const_pointer>::reference src) {
*ptr_cast<u64be>(dst) ^= *ptr_cast<u64be const>(src); src += 8;
}
int main() {
u8 fop[64], foq[64], fos[64],fot[64];
u8* foP=fop;
u8* foQ=foq;
u8* foS=fos;
u8* foT=fot;
xf64(foP,foQ);
XF64(foS, foT);
}
the inlining is aggressive enough to use inline functions instead of
#defines and I'm getting the following error: "invalid initialization
of reference of type ‘const unsigned char*&’ from expression of type
‘u8*’".
Does the inline lowercase match the macro uppercase?
code:
extern "C" {
#include <stdint.h>
}
typedef uint8_t u8;
typedef uint64_t u64be;
template <typename T>
struct itype {
typedef T value;
typedef T& reference;
typedef T const& const_reference;
typedef T* pointer;
typedef T const* const_pointer;
};
#define PTR_CAST(T, p) (reinterpret_cast<T*>(p))
#define XF64(dst,src) *PTR_CAST(u64be,dst) ^= *PTR_CAST(u64be
const,src); (src) += 8
template<typename T, typename P> inline T* ptr_cast(P* p) { return
reinterpret_cast<T*>(p); }
inline void xf64(itype<u8>:ointer dst,
itype<itype<u8>::const_pointer>::reference src) {
*ptr_cast<u64be>(dst) ^= *ptr_cast<u64be const>(src); src += 8;
}
int main() {
u8 fop[64], foq[64], fos[64],fot[64];
u8* foP=fop;
u8* foQ=foq;
u8* foS=fos;
u8* foT=fot;
xf64(foP,foQ);
XF64(foS, foT);
}