cancel
Showing results for 
Search instead for 
Did you mean: 

Fold Expression not working

AKlep.1
Associate II

I am using IDE 1.5.0 with the -std=gnu++17 flag set

When trying to use fold expression, the compiler throws an error.

5 REPLIES 5
KnarfB
Principal III

I'm not keen on new language features, but a simple test worked when test() called from main():

  template <typename... Ty>
  auto sum(Ty... args) {
    return (args + ...);
  }
 
  extern "C" int test()
  {
	 return sum(1,2,3);
  }

This is more a g++ question rather than STM.

Cartu38 OpenDev
Lead II

STM32CubeIDE 1.5.0 (1.4.2 is fine too) no issue to me if C++17 usage. According to me proper g++ switch is "-std=c++17" not "-std=gnu++17"

0693W000005C2WmQAK.jpg

AKlep.1
Associate II

0693W000005C2YOQA0.pngIt doesn't work for me and on -std = c ++ 17

AKlep.1
Associate II

Correction: works, but IDE emphasizes fold expression. Apparently we should expect further fixes.

Compiler (gcc/g++ here) is one thing, C editor code analysis engine another ...

Maybe CDT is late here (but 2017 post) ? https://www.eclipse.org/community/eclipse_newsletter/2017/april/article3.php

https://www.eclipse.org/forums/index.php/t/1086577/