microlibrary

ROM Facilities

ROM facilities are defined in the microlibrary static library’s microlibrary/rom.h/microlibrary/rom.cc header/source file pair.

Table of Contents

  1. Null-Terminated Strings

Null-Terminated Strings

The ::microlibrary::ROM::String type is used for handles to null-terminated strings that may be stored in ROM. This type defaults to char const *. A custom HIL can replace this type with a HIL specific version if MICROLIBRARY_TARGET is HARDWARE by doing the following:

If a function is being overloaded to work with null-terminated strings stored in RAM and null-terminated strings that may be stored in ROM, the ::microlibrary::ROM::String overload(s) must only be defined if MICROLIBRARY_ROM_STRING_IS_HIL_DEFINED is true since ::microlibrary::ROM::String defaults to char const *.

void foo( char const * string ) noexcept;

#if MICROLIBRARY_ROM_STRING_IS_HIL_DEFINED
void foo( ::microlibrary::ROM::String string ) noexcept;
#endif // MICROLIBRARY_ROM_STRING_IS_HIL_DEFINED

To create a string literal that can be stored in ROM, use the MICROLIBRARY_ROM_STRING() macro:

auto foo() noexcept -> ::microlibrary::ROM::String
{
    return MICROLIBRARY_ROM_STRING( "foo" );
}

A custom HIL can replace MICROLIBRARY_ROM_STRING() with a HIL specific version if MICROLIBRARY_TARGET is HARDWARE by doing the following: