port.h 562 字节
Newer Older
D
dlfnh  
dzhwinter 已提交
1 2
#pragma once

D
dzhwinter 已提交
3 4 5 6
#include <string>
#include <stdexcept>

#if !defined(_WIN32)
D
dlfnh  
dzhwinter 已提交
7 8
#include <dlfcn.h>     // for dladdr
#include <execinfo.h>  // for backtrace
D
dzhwinter 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#else
#include <Shlwapi.h>
#include <Windows.h>
namespace {

static void* dlsym(void *handle, const char* symbol_name) {
	FARPROC found_symbol;
    found_symbol = GetProcAddress((HMODULE)handle, symbol_name);

    if (found_symbol == NULL) {
    	throw std::runtime_error(std::string(symbol_name) + " not found.");
    }
    return (void*)found_symbol;
}
} // namespace anoymous

D
dlfnh  
dzhwinter 已提交
25
#endif