Utilities
Collaboration diagram for Utilities:
Classes | |
struct | argument_type< T > |
struct | argument_type< T(U)> |
Macros | |
#define | DECL(t) argument_type<void(t)>::type |
Wrap a type declaration so it can be passed with commas in it. More... | |
#define | IMPORT_FSTR_DATA(name, file) |
Link the contents of a file. More... | |
#define | STR(x) XSTR(x) |
#define | XSTR(x) #x |
Detailed Description
Macro Definition Documentation
◆ DECL
#define DECL | ( | t | ) | argument_type<void(t)>::type |
Wrap a type declaration so it can be passed with commas in it.
Example:
template <typename ElementType, size_t Columns> struct MultiRow { ElementType values[Columns]; }
These fail:
DECLARE_FSTR_ARRAY(myArray, MultiRow<double, 3>); DECLARE_FSTR_ARRAY(myArray, (MultiRow<double, 3>));
Use DECL like this:
DECLARE_FSTR_ARRAY(myArray, DECL((MultiRow<double, 3>)) );
Although for this example we should probably do this:
using MultiRow_double_3 = MultiRow<double, 3>; DECLARE_FSTR_ARRAY(myArray, MultiRow_double_3);
◆ IMPORT_FSTR_DATA
#define IMPORT_FSTR_DATA | ( | name, | |
file | |||
) |
Value:
__asm__(".section " ICACHE_RODATA_SECTION "." #name "\n" \
".incbin \"" file "\"\n" \
Link the contents of a file.
This provides a more efficient way to read constant (read-only) file data. The file content is bound into firmware image at link time.
We need inline assembler's .incbin
instruction to actually import the data. We use a macro STR() so that if required the name can be resolved from a #defined
value.
Use PROJECT_DIR to locate files in your project's source tree:
IMPORT_FSTR_DATA(myFlashData, PROJECT_DIR "/files/my_flash_file.txt");
Use COMPONENT_PATH within a component.
No C/C++ symbol is declared, this is type-dependent and must be done separately:
extern "C" FSTR::String myFlashData;
If the symbol is not referenced the content will be discarded by the linker.
◆ STR
#define STR | ( | x | ) | XSTR(x) |
◆ XSTR
#define XSTR | ( | x | ) | #x |