Problems building project for nucleo_l476rg board (STM32)

Hello to everyone. I am new in the community and also in platformio, i just hope someone can help me with the following problem I’ve had when building my project for my nucleo board.

First of all I am using macos environment. I have macosHighSierra 10.3.6 installed. The version of platformio that i have installed is 3.6.3. And the compiler used by platformio is clang-1000.10.44.4.

Here is the problem. When I try to build my project the following error shows up on the terminal:

/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/7.2.1/bits/cpp_type_traits.h:205:12: error: redefinition of ‘struct std::__is_integer’

I have tried to change the declaration in the cpp_type_traits.h to see if that would solve the problem, but another problem pops up:

.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/7.2.1/bits/stl_tempbuf.h:88:42: error: ‘__max’ is not a member of ‘__gnu_cxx::__numeric_traits’

The weird thing about this, is that this error only happens from time to time. Sometimes platformio build the project without throwing these errors, but after a while it comes back again. I think the error migth be in the compilation process but I am not sure.

Ive been stuck trying to look for this error, but had no luck. Hopefully someone here is able to give me some hints.

Thanks in advanced,
Javier

Can you provide your platformio.ini and the code with which this problem is reproducable in a minimal example?

First of all thank you for your reply maxgerhardt
The platform.ini is the following:

[env:nucleo_l476rg]
platform = ststm32
board = nucleo_l476rg
framework = mbed
build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT

And the structure of my project is the following. I am implementing the basic example of blinking led. But I am including several external libraries that I have written. These libraries have ifndef declaration and it looks like platformio is ignoring them, because I also get some warnings on re-declaration and re-definition.
I have one main.cpp file which calls to secondary file (Task file) that executes the blinking code. These file has one function to turn on the led and one to turn it off. It will call these functions depending on the current state of the program.

If our current state is led1 ON there is only one possible output which is go to state led1 OFF after some time. But if the current state is led1 OFF there are two possible outputs (requests): if the variable x > 10, just stop the execution, else go back to led1 ON after some period.

The code implemented creates one list of requests which contains all the possible outputs of the current state, therefore I check the value of the last request performed in order to know to which state I should go.

I hope the explanation is clear and the code of the blinking file as well. I will not include the MainBlock.h, but there, I have all my libraries included, as well as mbed.h, rtos.h and thread.h.

Please do not hesitate to ask for more information if it is not clear. Thanks in advance

#include “MainBlock.h” //mainblock.h contains the includes of the external libraries
// Header code defined in the model
DigitalOut myled1(LED1);

void __userImplemented__MainBlock__LED1on() {
myled1 = 1;
printf(“Led1 on.\n”);
}
void __userImplemented__MainBlock__LED1off(int val){
myled1 = 0;
printf(“Led1 off.\n”);
val = val + 1
printf(“Valor de x=%d\n”,val);
}

#define STATE__START__STATE 0
#define STATE__Led1on 1
#define STATE__Led1off 2
#define STATE__STOP__STATE 3

void MainBlock__LED1on() {
__userImplemented__MainBlock__LED1on();
}
void MainBlock__LED1off(int x) {
__userImplemented__MainBlock__LED1off(x);
}
void mainFunc__MainBlock(){
int period = 2;
int x = 0;

int __currentState = STATE__START__STATE;
attribute((unused)) request __req0;
attribute((unused))int *__params0[0];
attribute((unused)) request __req1;
attribute((unused))int *__params1[0];
attribute((unused))setOfRequests __list;
attribute((unused))size_t __myCond;
attribute((unused))request *__returnRequest;
char * __myname = “mainFunc__MainBlock”;

fillListOfRequests(&__list, __myname, NULL, __myCond, &__mainMutex);

/* Main loop on states */
while(__currentState != STATE__STOP__STATE) {
switch(__currentState) {
case STATE__START__STATE:
__currentState = STATE__Led1on;
break;

  case STATE__Led1on: 
        wait_us((period)*1000000);
        MainBlock__LED1off(x);
        __currentState = STATE__Led1off;
  break;
  
  case STATE__Led1off: 
        if (!(x > 10)) {
             makeNewRequest(&__req0, 241, IMMEDIATE, 1, (period)*1000000, (period)*1000000, 0, 
             __params0); //case for going back to led1 ON
             addRequestToList(&__list, &__req0);
  }
  if (x > 10) {
    makeNewRequest(&__req1, 249, IMMEDIATE, 0, 0, 0, 0, __params1); //case for stopping execution
    addRequestToList(&__list, &__req1);
  }
  if (nbOfRequests(&__list) == 0) {
    debug2Msg(__myname, "No possible request");
    __currentState = STATE__STOP__STATE;
    break;
  }
  __returnRequest = executeListOfRequests(&__list);
  clearListOfRequests(&__list);
  traceRequest(__myname, __returnRequest); //we ask for the first request of the list
   if (__returnRequest == &__req0) {
    MainBlock__LED1on();
    __currentState = STATE__Led1on;
  }
  else  if (__returnRequest == &__req1) {
    __currentState = STATE__STOP__STATE;
  }
  break;
}

}
return ;
}

Could you upload your whole project to github or dropbox/google drive for easier reproduction? There seems to be some substantial amount of code here.

Here is the link with all the project content.

https://drive.google.com/open?id=1Ya5AfSz_lx7qaPeHd0ZdfdwlU_0TXp8D

As a reminder, sometimes it compiles and executes the code correctly (sort of, there might be some function calls that I have to improve). But yes, from time to time I am able to build the project and upload it to my board.

Thanks again for your answer!!

Uhm well you do some weird stuff in that C++ header file… lib/TTool_Lib/defs.h

#ifndef DEFS_H
#define DEFS_H

#define bool int
#define true 1
#define false 0


#endif

bool is a built-in C++ type and your code is being compiled in a C++ compiler. I would not attempt to macro-define it to an integer. The C++ templates in C++ STD math library just blew up because of this.

Even for C, you have stdbool.h.

Comment all of this out in the defs.h and your project will compile every time. (BTW, compilation fails every time under Windows).

Thank you very much for your answer. I will give it a try later on the day and check if it solves my problem!!