On Friday, October 14, 2022 at 7:52:25 PM UTC+1, Alf wrote:
> inline string& message() { return Foo_<void>::message; }
Thanks Alf, the following compiled and linked fine for me:
template<class> struct Foo { static SimpleCrypto128 obj; };
template<class Dummy> SimpleCrypto128 Foo<Dummy>::obj;
inline SimpleCrypto128 &Scrypt128(void) { return Foo<void>::obj; }
I hadn't bothered trying using templates for this, because I figured if the compiler couldn't handle static variables in simple inline functions, then how could it cope with a template function. But anyway it has compiled and linked for me. Of course I'll have to test it to make sure there's only one object, but so far it looks good.
As for the peculiarities of the Texas Instruments compiler, well they at least have a finite list of its non-compliance. I've copy-pasted the following from the compiler manual:
6.2 Characteristics of TMS320C28x C++
The C28x compiler supports C++ as defined in the ANSI/ISO/IEC 14882:2003 standard (C++03), including these
features:
• Complete C++ standard library support, with exceptions noted below.
• Templates
• Exceptions, which are enabled with the --exceptions option; see Section 6.6.
• Run-time type information (RTTI), which can be enabled with the --rtti compiler option.
The compiler supports the 2003 standard of C++ as standardized by the ISO. However, the following features
are not implemented or fully supported:
• The compiler does not support embedded C++ run-time-support libraries.
• The library supports wide chars (wchar_t), in that template functions and classes that are defined for char are
also available for wchar_t. For example, wide char stream classes wios, wiostream, wstreambuf and so on
(corresponding to char classes ios, iostream, streambuf) are implemented. However, there is no low-level file
I/O for wide chars. Also, the C library interface to wide char support (through the C++ headers <cwchar> and
<cwctype>) is limited as described above in the C library.
• If the definition of an inline function contains a static variable, and it appears in multiple compilation units
(usually because it’s a member function of a class defined in a header file), the compiler generates multiple
copies of the static variable rather than resolving them to a single definition. The compiler emits a warning
(#1369) in such cases.
• The export keyword is not implemented.