I intend to use a c++ lib from a dotnet core application. I am trying to create a Wrapper around this c++ lib.
The class I try to wrap is Client ( see : https://github.com/theomessin/jetbridge/blob/develop/Client/Client.hh ) :
#pragma once
#include <Windows.h>
#include <future>
#include <map>
#include "../Protocol/Protocol.hh"
namespace jetbridge {
class Client {
private:
void* simconnect = 0;
std::map<int, std::promise<Packet*>*> requests;
public:
Client(void* simconnect);
void handle_received_client_data_event(void* event);
Packet* request(char data[], int timeout = 1000);
};
} // namespace jetbridge
As you can see, it includes future
I created a C++ CLR project, added the native c++ Client lib and created simple ClientWrapper.h
/ ClientWrapper.cpp
files :
ClientWrapper.h
#pragma once
#include "../Client/Client.hh"
using namespace System;
namespace ClrClient {
public
ref class ClientWrapper {};
}
ClientWrapper.cpp
#include "pch.h"
#include "ClientWrapper.h"
I am not able to compile this code, because <future>
is not supported when compiling with /clr
or /clr:pure
I did my research and found several discussions where it was suggested to first wrap the c++ class into another c++ class that does not expose the future.
Client.hh > ClientNativeWrapper.h > ClientClrWrapper.h
I understand this suggestion but I don't understand how to proceed to "not expose" this #include <future>
by including Client.hh
in another c++ class, it will still be visible when compiling the c++/cli wrapper class in the end.