Elements 6.1.2
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
ThisModule.cpp
Go to the documentation of this file.
1
23
24#include <cstddef>
25#include <dlfcn.h>
26
27#include "ElementsKernel/FuncPtrCast.h" // for FuncPtrCast
28#include "ElementsKernel/ModuleInfo.h" // for ModuleInfo
29
30namespace Elements {
31namespace System {
32
34 static ModuleInfo this_module;
35 if (this_module.isEmpty()) {
36 void* handle = ::dlopen(nullptr, RTLD_LAZY);
37 if (nullptr != handle) {
38 void* func = ::dlsym(handle, "main");
39 if (nullptr != func) {
40 this_module = ModuleInfo(FuncPtrCast<void*>(func));
41 }
42 }
43 }
44
45 return this_module;
46}
47
48} // namespace System
49} // namespace Elements
OS specific details to access at run-time the module configuration of the process.
defines a Small helper function that allows the cast from void * to function pointer
header to get the module info statically
ELEMENTS_API const ModuleInfo & getThisExecutableInfo()
Definition: ThisModule.cpp:33