Skip to content

Commit cd7ed0f

Browse files
committed
Disable dynamic loading when <dlfcn.h> is not available
1 parent aac23be commit cd7ed0f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libcppunitx/module_loader.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,29 @@ namespace
106106
void module::open(const char *const name)
107107
{
108108
close();
109+
#if HAVE_DLFCN_H
109110
_native_handle = dlopen(name, RTLD_LAZY);
111+
#endif
110112
}
111113

112114
void module::close()
113115
{
116+
#if HAVE_DLFCN_H
114117
native_handle_type handle = nullptr;
115118
std::swap(_native_handle, handle);
116119
if (handle != nullptr) {
117120
dlclose(handle);
118121
}
122+
#endif
119123
}
120124

121125
void *module::sym(const char *symbol)
122126
{
127+
#if HAVE_DLFCN_H
123128
return dlsym(_native_handle, symbol);
129+
#else
130+
return nullptr;
131+
#endif
124132
}
125133

126134
void ltmodule::open(const char *const name)

0 commit comments

Comments
 (0)