1

I am trying to compile a C++ code, in this code I am defining two large arrays of 405 elements each.

double a [405] = {...};
double b [405] = {...};

Then I convert these into vectors using this function:

std::vector<double> ArrayToVector(double* arr, size_t arr_len) {
return std::vector<double>(arr, arr + arr_len);
}

Then I do the conversion:

std::vector<double> coefs_vec= ArrayToVector(a,405);
std::vector<double> ft_vec= ArrayToVector(b,405);

And here were the overflow occurs and I get those errors:

 error: sram_out/sram.elf section `.text' will not fit in region `int_main'
 error: region `int_main' overflowed by 35816 bytes
 collect2: error: ld returned 1 exit status

I tried using dynamic memory for some previous used variables but the problem is mainly caused by this big arrays. Is there a way I can solve this problem? Maybe a better way to define those arrays with less memory usage.

  • Does [Region ram overflowed and section .text will not fit region ram](https://stackoverflow.com/a/42044660/7582247) help? – Ted Lyngmo Oct 14 '20 at 08:51
  • Why not do `std::vector coefs_vec{ ... };` directly? Why do you need `a`? – Ted Lyngmo Oct 14 '20 at 11:10
  • @TedLyngmo I get this error ´error: in C++98 'features_vec' must be initialized by constructor, not by '{...}'´´ and ´error: could not convert from '' to 'std::vector –  Oct 14 '20 at 12:06
  • Do you need to use C++98? It's over 2 decades old and the language has changed a lot since then. What compiler and compiler version are you using? – Ted Lyngmo Oct 14 '20 at 12:07

0 Answers0