1 (edited by KissInno 2020-02-08 19:49:25)

Topic: Visual Studio Code, compilation error (while IDE is working)

Visual Studio Code, VSC, is REALLY much better than IDE. Once you have tried it, it's almost impossible to come back to Arduino IDE.

But bad luck, VSC detects error while compiling my RemoteXY project:  "narrowing conversion of '-110' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]"

This VSC compilation error looks normal because some of the uint8_t are declared as negative value, while thy should remain between 0 mini to 255 maxi:

// RemoteXY configurate 
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
// int16_t RemoteXY_CONF[] =  this does not work, even with IDE
  { 255,35,0,186,0,26,8,8,8,6,
  0,39,82,40,3,-110,85,18,6,0,
  16,75,105,115,115,46,73,110,110,111,
  118,97,116,105,111,110,64,103,109,97,
  105,108,46,99,111,109,0,66,129,98,
-30,11,5,102,8,7,16,1,16,149,
  129,0,102,-27,12,3,83,11,18,6,
  1,17,84,104,114,111,116,108,101,49,
  0,65,4,-35,28,9,9,84,20,9,

For strange reasons, IDE 1.8.10 does compile without problem those negative uint8_t and my project works fine (ESP32 & wifi connection to RemoteXY smartphone). For time being, I 've been using Copy/Paste from VSC to IDE to upload my ESP32... It works but it is boring.

I tried to do replace "uint8_t RemoteXY_CONF[] =" by "int16_t RemoteXY_CONF[] =", VSC & IDE do compile/upload without error but it does not work.

Does anybody know why I'm getting these negatives declarations within my RemoteXY project? If I knew the cause, I could try to write my RemoteXY project differently.

Thanks for your help.

2 (edited by Guillaume 2020-04-17 20:16:59)

Re: Visual Studio Code, compilation error (while IDE is working)

Link to your remotexy project ?

Shit workaround for the error, add this in your platformio.ini : src_build_flags = -Wno-error=narrowing

3

Re: Visual Studio Code, compilation error (while IDE is working)

platformio.ini : src_build_flags = -Wno-error=narrowing

This did the job, Visual Studio Code does compile & upload :-))))) Thanks you so much Guillaume.

BTW, I forgot to mention that I've been using the RemoteXY-master Lib from FedericoBusero to make RomteXY working in Wifi with my ESP32.

https://github.com/FedericoBusero/RemoteXY