From 79eca1d58eb55aa0fc59f9ae0d05328f50340616 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 12 Aug 2014 08:50:14 +0200 Subject: [PATCH] check both versions of REFPROP on windows always Signed-off-by: Ian Bell --- .../REFPROP/REFPROPMixtureBackend.cpp | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp index 5c61e4bc..ccd85a32 100644 --- a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp +++ b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp @@ -361,18 +361,22 @@ bool load_REFPROP() { // Load it #if defined(__ISWINDOWS__) - #if defined(ENV64BIT) - // 64-bit code here. - TCHAR refpropdllstring[100] = TEXT("refprp64.dll"); - RefpropdllInstance = LoadLibrary(refpropdllstring); - #elif defined (ENV32BIT) + /* We need this logic on windows because if you use the bitness + * macros it requires that the build bitness and the target bitness + * are the same which is in general not the case. Therefore, checking + * both is safe + */ + // First try to load the 64-bit version + // 64-bit code here. + TCHAR refpropdllstring[100] = TEXT("refprp64.dll"); + RefpropdllInstance = LoadLibrary(refpropdllstring); + + if (RefpropdllInstance==NULL){ + // That didn't work, let's try the 32-bit version // 32-bit code here. - TCHAR refpropdllstring[100] = TEXT("refprop.dll"); - RefpropdllInstance = LoadLibrary(refpropdllstring); - #else - // INCREASE ROBUSTNESS. ALWAYS THROW AN ERROR ON THE ELSE. - #error "Must define either ENV32BIT or ENV64BIT" - #endif + TCHAR refpropdllstring32[100] = TEXT("refprop.dll"); + RefpropdllInstance = LoadLibrary(refpropdllstring32); + } #elif defined(__ISLINUX__) RefpropdllInstance = dlopen ("librefprop.so", RTLD_LAZY);