Calculator logic that works with any operators written in .dll
- Download the latest release, or build it yourself from the source files and the cmake build system
For example, commands for Windows (using ninja):
cmake -B ./.build -G Ninja
cd ./.build
ninja
- Run the compiled file, for example:
.\calculator.exe
- Write a mathematical expression in the console and get the answer:
1 - sin(-5 + (-6)^2) / 10 + !2
> 3.0404
- Use dllScheme.h
#ifndef FILE_H
#define FILE_H
#if defined(MYLIBRARY)
#define LIBRARY_EXPORT __declspec(dllexport)
#else
#define LIBRARY_EXPORT
#endif
#include <stdexcept>
#include <vector>
#include "dllData.h"
#include "../interface/interfaces.h"
extern "C" Data LIBRARY_EXPORT getData() noexcept;
extern "C" void LIBRARY_EXPORT doMath(StackT& data);
#endif
- Include it to your code
#include "../dllScheme.h"
- Write REQUIRED functions:
Data LIBRARY_EXPORT getData() noexcept
void doMath(StackT& stack)
-
Use references
-
Don't forget to pre-assemble the libraries