Local Building - does not compile with warnings?

If there are warnings, will local building fail compiling? Below are the errors that i see that otherwise complies fine on the webIDE

applications/testingfull/Adafruit_mfGFX.cpp: In member function 'void Adafruit_G
FX::drawChar(int16_t, int16_t, unsigned char, uint16_t, uint16_t, uint8_t)':
applications/testingfull/Adafruit_mfGFX.cpp:457:7: warning: 'line' may be used u
ninitialized in this function [-Wmaybe-uninitialized]
       if (line & 0x80) {
In file included from applications/testingfull/app.cpp:7:0:
applications/testingfull/Touch_4Wire.h:35:1: warning: 'typedef' was ignored in t
his declaration
applications/testingfull/app.cpp: In function 'const char* convWeekday(byte)':
applications/testingfull/app.cpp:741:1: warning: control reaches end of non-void
 function [-Wreturn-type]
applications/testingfull/app.cpp: In function 'const char* convMonth(byte)':
applications/testingfull/app.cpp:759:1: warning: control reaches end of non-void
 function [-Wreturn-type]
applications/testingfull/MMA7660.cpp: In member function 'uint8_t MMA7660::read(
applications/testingfull/MMA7660.cpp:55:12: warning: 'data_read' may be used uni
nitialized in this function [-Wmaybe-uninitialized]
     return data_read;
In file included from applications/testingfull/Touch_4Wire.cpp:9:0:
applications/testingfull/Touch_4Wire.h:35:1: warning: 'typedef' was ignored in t
his declaration
applications/testingfull/Touch_4Wire.cpp: In member function 'TSPoint TouchScree
applications/testingfull/Touch_4Wire.cpp:195:25: warning: 'z' may be used uninit
ialized in this function [-Wmaybe-uninitialized]
   return TSPoint(x, y, z);
-none-eabi/lib/armv7-m\libg_nano.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status

Hi @wesner0019

See this post for what the linker error for _sbrk means. You can safely ignore the warnings, that is just gcc being strict.

@bko, I will ignore them but the compiler doesn’t and stops creating my user firmware to flash locally.

Is there a setting some where to ignore warnings and not turn them into errors?

Hi @wesner0019

Sorry I didn’t explain more. You got a whole bunch of warnings (which are safe to ignore) and one linker error which I have quoted above. That is what stopped the compilation. You need to track down what you are calling that is trying to allocation memory and fix or replace it.

Well there might be something broken with your setup, I checked the Adafruit_mfGFX.cpp file for uninitialized line variable and it should be defined in all cases. And the rest of warnings seems somewhat fishy too. I seen similar errors solved using this code on top of your code:

#include "application.h"

Not sure if it helps, but worth the try.

There is some rather advanced thread about the problem:

@lami, no luck,

These are the files Im trying to compile

Can you post content of the main file, the one with setup() and loop()?

Hi @wesner0019

here are @mdma’s instructions for tracking down your linker problem:

Here’s how to find out which function is causing the problem:

  • add a function extern “C” void* _sbrk() { return NULL; } to your program. This is only temporary and will fill in the missing function so the code links.
  • open the user-part.lst file that is produced alongside your compiled application codesearch for _sbrk to find which function is calling that. (It’s usually _malloc_r)then search for _malloc_r and see which function is calling that. That will tell you which function is trying to allocate memory directly via _malloc_r rather than via malloc()

I dont get the_sbrk error when I remove the const in the below function, but then I get a different error

const char* convMonth(byte value) { // converts 1-12 to the correstponding month
  switch (value) {
  case 1: return "January";
  case 2: return "February";
  case 3: return "March";
  case 4: return "April";
  case 5: return "May";
  case 6: return "June";
  case 7: return "July";
  case 8: return "August";
  case 9: return "September";
  case 10: return "October";
  case 11: return "November";
  case 12: return "December";


Try this:

static const char _months[12][10] = {"January","February","March","April","May","June","July","August","September","October","November","December"};

const char* convMonth(byte value) {
  return _months(value-1);

@bko, also tried you other example. Is this what I’m looking for?

@bko, I completely removed that function and I get the same _sbrk error.

@lami, below is my app code:

***Remove code

Well, I should always remember to read the end of the thread:

The current Photon time functions have this bug. It was added the bug backlog with high priority, but I have not seen the fix go by yet.

1 Like

Wow, that is amazing piece of code! I was expecting something simpler, where would be easier to try disabling parts of code until a culpri can be foundt. But it seems @bko discovered something! I can’t really help much when some internal working is involved as I am - let’s say - too scared to dive into the firmware code. Sorry :smile:

@bko, @lami, thanks, I’ll try disabling the time functions next.

Folks, it turns out that _sbrk() is called by functions in the Time class which are calling malloc_r instead of malloc. When @mdma gets back, he should be able to fix this quickly. This only affects the develop branch.

1 Like

Thanks, I removed all time related code and now it is compiling. :smile:

1 Like

@peekay123, do you know when mdma will get back?

I am currently on hold for doing any local compiling as my code has to have time functions. Do you know what files I would have to edit in the develop branch to change mallocr to malloc? Just so I can start testing my code?

Thanks for any help,

Yup… next week :smile: