-1
Hello, I am working on a project for Windows that has a structure (of Windows itself) that changes according to the architecture of the system (x86/x64), how to return the correct structure for a function based on the information of which Windows architecture the user is using?
For example:
struct s_arch_x86
{
uint32_t callback0;
uint32_t flags;
uint32_t callback1;
};
struct s_arch_x64
{
uint64_t callback0;
uint32_t flags;
uint32_t flags2;
uint64_t callback1;
};
template < typename T1, typename T2 >
auto get_struct_based_on_arch(uint32_t arch, uintptr_t address)
{
return arch == 32 ? reinterpret_cast<T1>(address) : reinterpret_cast<T2>(address);
}
get_struct_based_on_os_arch<s_arch_x86*, s_arch_x64*>(get_os_arch(), ptr)->callback1 = 0;
In MSVC with C++17 I have the following error when compiling the above code: error C2446: ':': no conversion from 'T2' to 'T1'
Is it for all these versions? (not that you need any, probably in the worst case
#ifdef
resolves at all)– Bacco
No, any of it
– cYeR