Download Compiler Reference Manual

Transcript
12. Appendix A : Pragma Support
#pragma export_autodef_macro "<output_macro_name>",
<output_macro_value>
The following lines in eTPU source:
#define TEST_INIT_HSR 7
#define TEST_STR "xyz"
#pragma export_autodef_macro "ETPU_TEST_INIT_HSR",
TEST_INIT_HSR
#pragma export_autodef_macro "TEST_STR", TEST_STR
Results in the following in the auto-defines file:
// exported autodef macros from user "#pragma
export_autodef_macro" commands
#define ETPU_TEST_INIT_HSR 7
#define TEST_STR "xyz"
The standard header file "ETpu_Std.h" has a few "helper macros" available that can
potentially make the eTPU source easier to read. Using the macros like:
#define TEST_ODD_PARITY_FM 1
#pragma export_autodef_macro EXPORT_AUTODEF_MACRO
(TEST_ODD_PARITY_FM)
#pragma export_autodef_macro EXPORT_AUTODEF_MACRO_PRE
("ETPU_", TEST_ODD_PARITY_FM)
Results in:
// exported autodef macros from user "#pragma
export_autodef_macro" commands
#define TEST_ODD_PARITY_FM 1
#define ETPU_TEST_ODD_PARITY_FM 1
There is also a pragma to export any user-defined text. Note that this text must be
parseable by whatever compiler processes the auto-defines file when compiling host code,
or it will break the compilation. The export text #pragma has this syntax:
#pragma export_autodef_text "<user_defined_text>"
The text must use C escape sequences when necessary, and can even include newlines for
the output. For example:
#pragma export_autodef_text "#define EXPORT_AUTODEF_VAL 1"
#pragma export_autodef_text "#define
EXPORT_AUTODEF_STR \"abc\""
#pragma export_autodef_text "#define
EXPORT_AUTODEF_FUNC_MACRO(ARG1, ARG2) \\\n ARG1 = ARG2;"
(C) 2007-2015
Compiler Reference Manual, page 137