Binary Compatibility Object Model for C++ (BiCOMC) is library for surporting binary compatibility to C++ classes.
- C++ 03 or higher support
- __VA_ARGS__ support
- SFINAE support
Just add include
to the include directory path.
-
Move to directory of BiCOMC
-
Install BiCOMC (just once)
mkdir build && cd build cmake .. cmake --build . --target install
-
Link BiCOMC to your project
find_package(BiCOMC CONFIG REQUIRED) add_executable(YourTarget ...) # or add_library(...) target_link_libraries(YourTarget BiCOMC)
-
Check the absolute path of
include
-
Include the path to your project using
include_directories
include_directories("path/of/bicomc/include") add_executable(YourTarget ...) # or add_library(...)
// iprinter.h
#pragma once
#include <bicomc/object.h>
BICOMC_INTERFACE(IPrinter)
BICOMC_DECL_METHOD(print, void(char const* message), 1)
BICOMC_INTERFACE_END(IPrinter)
// printer.h
#pragma once
#include <iostream>
#include "iprinter.h"
class Printer : public IPrinter {
BICOMC_OVERRIDE(IPrinter)
BICOMC_OVER_METHOD(print, void(char const*))
BICOMC_OVERRIDE_END(IPrinter)
public:
Printer() : BICOMC_OVERRIDE_INIT() {}
void print(char const* message) {
std::cout << message;
}
};
// main.cpp
#include "printer.h"
int main() {
bcc::Object* p = new Printer();
IPrinter& printer = bicomc_cast<IPrinter&>(*p);
printer.print("Hellow world!!");
p->destroy(); // as a 'delete p'
return 0;
}
BiCOMC is distributed under the Apache License 2.0 and it uses open source softwares shown in the NOTICE file.