This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What C++ standard does ARMCC support and why does this template not instantiated?

Hi all,

I have a project with C and C++, I'm compiling it with armcc v5.06 (Keil uVision 5):

--c99 -c --cpu Cortex-M4.fp -g -O3 --apcs=interwork --split_sections -I../Core/Inc -I../Drivers/STM32F4xx_HAL_Driver/Inc -I../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I../FreeRTOS/Source/include - ...[removed includes for cleanliness]
-D__UVISION_VERSION="517" -D_RTE_ -DSTM32F469xx -DUSE_HAL_DRIVER -DMY_MODULE_ID="3" -DDUO8 -DTOUCH_GFX -DSTM32F469xx -o "..\..\..\Projects\MDK-ARM\Framework\*.o" --depend "..\..\..\Projects\MDK-ARM\Framework\*.d"

As I checked here: ARM Compiler toolchain Compiler Reference Version 5.03

--c99

This option enables the compilation of C99 source code. It enforces C only, and C++ syntax is not accepted.

1) If that's so, How Is my C++ code compiling? 

As I checked here: ARM Compiler User Guide Version 6.6.1 

The default language standard for C++ code is gnu++98. To specify a different source language standard, use the -std=name option.

2) but based on the table in the link, do I have C++03 standard or something else?

---------------------------------------------------------------------------------------------------------------------------

Now, for the more interesting part:

I have this templated class in DoubleBufferedVideoController.hpp:

template <uint32_t no_streams, uint32_t width, uint32_t height, uint32_t stride, touchgfx::Bitmap::BitmapFormat output_format>
class DoubleBufferedVideoController : public touchgfx::VideoController
{
public:
    DoubleBufferedVideoController()
        : VideoController(),
          bufferRGB(0), sizeBufferRGB(0), topBufferRGB(0),
          semDecode(0), mutexBuffers(0)
    { //something
    }
    
    ...
}

And this in another .cpp file:

#include <DoubleBufferedVideoController.hpp>

DoubleBufferedVideoController<1, 320, 800, 320*2U, Bitmap::RGB565> vdt;

void videoTaskFunc()
{
	vdt.decoderTaskEntry();
}

As I understand, the template should be instantiated and the constructor called for this global variable, but it isn't. in debug I find that it's NULL, and the constructor never gets used.

When I changed it to using a static variable it worked:

#include <DoubleBufferedVideoController.hpp>

DoubleBufferedVideoController<1, 320, 800, 320*2U, Bitmap::RGB565>* vdt;

VideoController& VideoController::getInstance()
{	
	if(!vdt)
	{
		static DoubleBufferedVideoController<1, 320, 800, 320*2U, Bitmap::RGB565> vd_350;
		vdt = &vd_350;
	}
	return *vdt;
}

void videoTaskFunc()
{
    VideoController::getInstance();
	vdt->decoderTaskEntry();
}

Can someone please clarify for me what I'm missing as to why the first code doesn't work? I thought it might be a compiler standard issue which is why I added the above questions too.

Any help is appreciated!