MCPcopy Create free account
hub / github.com/Kitware/CMake / main

Function main

Tests/Plugin/src/example_exe.cxx:23–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21#endif
22
23int main()
24{
25 std::string const libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR
26 "/" EXAMPLE_EXE_MOD_PREFIX "example_mod_1" EXAMPLE_EXE_MOD_SUFFIX;
27 DynamicLoader::LibraryHandle handle = DynamicLoader::OpenLibrary(libName);
28 if (!handle) {
29 // Leave the .c_str() on this one. It is needed on OpenWatcom.
30 std::cerr << "Could not open plugin \"" << libName.c_str() << "\"!"
31 << std::endl;
32 return 1;
33 }
34 DynamicLoader::SymbolPointer sym =
35 DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function");
36 if (!sym) {
37 std::cerr << "Could not get plugin symbol \"example_mod_1_function\"!"
38 << std::endl;
39 return 1;
40 }
41#ifdef __WATCOMC__
42 int(__cdecl * f)(int) = (int(__cdecl*)(int))(sym);
43#else
44 int (*f)(int) = reinterpret_cast<int (*)(int)>(sym);
45#endif
46 if (f(456) != (123 + 456)) {
47 std::cerr << "Incorrect return value from plugin!" << std::endl;
48 return 1;
49 }
50 DynamicLoader::CloseLibrary(handle);
51 return 0;
52}

Callers

nothing calls this directly

Calls 2

c_strMethod · 0.80
fFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…