Commit c3701240 authored by Artur Wojcik's avatar Artur Wojcik
Browse files

fix function attributes

parent caf6e335
......@@ -28,15 +28,15 @@
#include <migraphx/make_op.hpp>
#include <test.hpp>
#ifndef _WIN32
#define EXPORT_SYMBOL R"migraphx(extern "C")migraphx"
#ifdef _WIN32
#define EXPORT_SYMBOL R"migraphx(__declspec(dllexport) )migraphx"
#else
#define EXPORT_SYMBOL R"migraphx(__declspec(dllexport))migraphx"
#define EXPORT_SYMBOL
#endif
// NOLINTNEXTLINE
const std::string add_42_src = EXPORT_SYMBOL R"migraphx(
int add(int x)
extern "C" int add(int x)
{
return x+42;
}
......@@ -69,18 +69,14 @@ std::function<F> compile_module(const migraphx::module& m, const std::string& fl
{
migraphx::cpp_generator g;
g.fmap([](auto&& name) { return "std::" + name; });
g.create_function(g.generate_module(m).set_attributes({"extern \"C\""}));
g.create_function(g.generate_module(m).set_attributes({EXPORT_SYMBOL "extern \"C\""}));
return compile_function<F>(preamble + g.str(), flags, m.name());
}
TEST_CASE(simple_run)
{
#ifdef _WIN32
auto f = compile_function<int(int)>(add_42_src, "", "?add@@YAHH@Z");
#else
auto f = compile_function<int(int)>(add_42_src, "", "add");
#endif
EXPECT(f(8) == 50);
EXPECT(f(10) == 52);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment