This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

error: template with C linkage

extern "C" {
#include <stdio.h>
#include <stdlib.h>
}
#include <string>
/*********************************************************************
*
*       main()
*
*  Function description
*   Application entry point.
*/
void main(void) {
  int i;

  for (i = 0; i < 100; i++) {
    printf("Hello World %d!\n", i);
  }
  do {
    i++;
  } while (1);
}

I am in the process of building software to drive a bare metal widget based on the nrf52840 - currently against the DK board. We have an in-house abstraction interface layer that goes between the hardware specific code and the user facing app. This s in c++. When I compile this I get error: template with C linkage in the library files i am trying to use. I have reproduced the issue in the simple example code that ses starts with. The errors are:

Compiling 'main.cpp'
1> In file included from /usr/include/newlib/c++/6.3.1/bits/stringfwd.h:40:0,
1>                  from /usr/include/newlib/c++/6.3.1/string:39,
1>                  from /home/paulc/Documents/SEGGER Embedded Studio for ARM Projects/Executable_1/main.cpp:53:
1> /usr/include/newlib/c++/6.3.1/bits/memoryfwd.h:63:3: error: template with C linkage
1> /usr/include/newlib/c++/6.3.1/bits/memoryfwd.h:66:3: error: template specialization with C linkage
1> /usr/include/newlib/c++/6.3.1/bits/memoryfwd.h:70:3: error: template with C linkage

my environment is:

  • linux mint/ubuntu bionic/tara
  • libnewlib-arm-none-eabi
  • gcc-arm-none-eabi
  • SES 3.4

i am not a c++ developer but rather a rusty c developer.

Any suggestions would be most welcome

Cheers Paul

  • The things we learn - usually new ways to shoot ourselves in the foot. Things that I didn't realise but now know:

    1) SES uses its own libraries and code. 

    2)  You don't need to add the standard Linux ARM bare metal tool chain - if you do you get these and many other interesting errors

    3) you need to download using the SES packagemanager the stlport lib for what I am doing

    Cheers Paul

Related