Join GitHub today
Linking with MY_BASIC
It is also possible to link with MY-BASIC as a library, instead of copying the kernel files to target projects. This page shows how to expose MY-BASIC functions to make a linkable library.
All functions tagged with
my_basic.h are public functions. Although they were not declared as exposing by default in MY-BASIC, it is easy to modify that.
Different compilers recognize different compilation attributes specified by compiler vendors for symbol storage information. Consider picking proper attributes for your working compiler.
__declspec(dllexport) inside a shared library to export symbols, uses
__declspec(dllimport) when reference symbols from a shared library. In case of static linking no
declspec is required.
GCC: refers to "Visibility".
Xcode: refers to "Controlling Symbol Visibility".
Other compilers: refers to guide document provided by compiler vendors.
Use the more portable
MBAPI declaration as follow, to expose all
#if !defined MBAPI # if defined _MSC_VER # if defined INTE_COMPILE /* Define INTE_COMPILE as export when build a DLL */ # define MBAPI __declspec(dllexport) # else /* Otherwise import for referring */ # define MBAPI __declspec(dllimport) # endif # else # define MBAPI __attribute__ ((visibility("default"))) # endif #endif
Private refers to functions which are only "visible" by other functions in a single C compilation unit (a *.c file), and cannot be referenced outside that source file. There's no need to care about these functions for most cases.
Although you can expose these static function by changing the symbol visibility if you really wish to. Follow these steps to make it:
- Remove the
- Add an
- Make sure your project referencing the MY-BASIC library could include the declaration of exposed functions, you can simply add them to
my_basic.hor declare them in your projects