ARM-GNU compilation of instrumented code causes error: specializing member

Technote (troubleshooting)


Problem(Abstract)

Attempts to compile code instrumented by IBM Rational Test RealTime (TestRT) result in compilation error status 1.

Symptom

The compilation fails with error similar as below.


test.cpp: Compiling...

arm-none-eabi-g++.exe -c -mcpu=arm926ej-s -funsigned-bitfields -ffunction-sections -mlong-calls -fno-use-cxa-atexit -marm -g "-DTPO=29" "-ID:\Application\System" "-ID:\Application\Drivers\Common" "test_aug.cpp" -o "test.o"

test.cpp:18:6: error: specializing member 'MyClass<10>::_AttClassField::_att_tmpl_text' requires 'template<>' syntax

status 1

---


Cause

This problem occurs when the instrumentor attolccp adds methods to the template class.



EXAMPLE:


Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.




#include <stdio.h>

template <int T>

class MyClass

{

public:

void print() { printf("%d\n", T); }

};

int main(int argc, char* argv[])

{

MyClass<10>().print();

return 0;

}



#include <stdio.h>

template <int T>

class MyClass

{

public:

void print() { printf("%d\n", T); }

};

int main(int argc, char* argv[])

{

MyClass<10>().print();

return 0;

}



During instrumentation, attolcpp adds several methods to the template class MyClass.



EXAMPLE


template < int T > char *FixedPoint< T>
( ) const { return _ATT_TMPL_NOTE_NOT_COMPUTED; }.
attolcpp also provide its specialization:
char *MyClass< 10> ::_AttClassField::_att_tmpl_text ( ) const {
return
(char *)"MyClass< 10> "; }


When you compile source through the ARM-GNU compiler, the compiler can raise a syntax error. Other compilers like MinGW can be less strict and accept specialization even without template <>.

Specialization of a method include the template keyword with empty angular brackets before the prototype of the template function.


Therefore the function must look look like the following function.




template<> char *MyClass< 10> ::_AttClassField::_att_tmpl_text ( )
const
{ return (char *)"MyClass< 10> "; }


Resolving the problem


Remove the --old_specializations from the Analyzer file configuration.


  1. Open the Target Deployment Port (xdp) with the editor.


  2. Go to Parser Settings > Analyzer file configuration and remove the following line

    --old_specializations.


  3. Make a Save & Generate.








Description of this option :



-----------------------------------------
--old_specializations
--no_old_specializations


Enable or disable acceptance of old-style template specializations That means specializations that do not use the template<> syntax. Default behavior is specified by DEFAULT_OLD_SPECIALIZATIONS_ALLOWED. This option is valid only in C++ mode.
-------------------------------------------



Rate this page:

(0 users)Average rating

Document information


More support for:

Rational Test RealTime
Runtime Analysis: C++

Software version:

7.5, 7.5.0.1, 7.5.0.2, 7.5.0.3, 7.5.0.4, 7.5.0.5, 7.5.0.6, 8.0, 8.0.0.1, 8.0.0.2, 8.0.0.3, 8.0.0.4, 8.0.0.5

Operating system(s):

Windows

Reference #:

1613770

Modified date:

2014-04-08

Translate my page

Machine Translation

Content navigation