aselectroworks / Arduino-FT6336U

FocalTech FT6336U (Self-Capacitive Touch Panel Controller) library for Arduino.
MIT License
38 stars 10 forks source link

Compile errors using vscode #1

Closed ysyt closed 3 years ago

ysyt commented 3 years ago

When compiling it mainly complains about the order of the variable declarations Swapping line 192 and 193 in the header file fixes the issue.

Compile log:

In file included from lib\Arduino-FT6336U\src\FT6336U.cpp:9:0: lib\Arduino-FT6336U\src\FT6336U.h:127:14: warning: extra tokens at end of #ifdef directive

ifdef ESP32 || ESP8266

          ^

lib\Arduino-FT6336U\src\FT6336U.cpp:16:14: warning: extra tokens at end of #ifdef directive

ifdef ESP32 || ESP8266

          ^

In file included from lib\Arduino-FT6336U\src\FT6336U.cpp:9:0: lib\Arduino-FT6336U\src\FT6336U.h: In constructor 'FT6336U::FT6336U(uint8_t, uint8_t)': lib\Arduino-FT6336U\src\FT6336U.h:193:22: error: 'FT6336U::rst_n' will be initialized after [-Werror=reorder]
uint8_t rst_n = -1; ^ lib\Arduino-FT6336U\src\FT6336U.h:192:22: error: 'uint8_t FT6336U::int_n' [-Werror=reorder] uint8_t int_n = -1; ^ lib\Arduino-FT6336U\src\FT6336U.cpp:13:1: error: when initialized here [-Werror=reorder] FT6336U::FT6336U(uint8_t rst_n, uint8_t int_n) ^ In file included from lib\Arduino-FT6336U\src\FT6336U.cpp:9:0: lib\Arduino-FT6336U\src\FT6336U.h: In constructor 'FT6336U::FT6336U(uint8_t, uint8_t, uint8_t, uint8_t)': lib\Arduino-FT6336U\src\FT6336U.h:193:22: error: 'FT6336U::rst_n' will be initialized after [-Werror=reorder]
uint8_t rst_n = -1; ^ lib\Arduino-FT6336U\src\FT6336U.h:192:22: error: 'uint8_t FT6336U::int_n' [-Werror=reorder] uint8_t int_n = -1; ^ lib\Arduino-FT6336U\src\FT6336U.cpp:17:1: error: when initialized here [-Werror=reorder] FT6336U::FT6336U(uint8_t sda, uint8_t scl, uint8_t rst_n, uint8_t int_n) ^ lib\Arduino-FT6336U\src\FT6336U.cpp: In member function 'uint8_t FT6336U::readByte(uint8_t)': lib\Arduino-FT6336U\src\FT6336U.cpp:254:12: warning: 'rdData' may be used uninitialized in this function [-Wmaybe-uninitialized] return rdData; ^ cc1plus.exe: some warnings being treated as errors In file included from src\main.cpp:15:0: lib/Arduino-FT6336U/src/FT6336U.h:127:14: warning: extra tokens at end of #ifdef directive

ifdef ESP32 || ESP8266

          ^
fvanroie commented 3 years ago

I still see a lot of compiler warning when compiling with this library.

Compiling .pio/build/wt32-sc01/lib359/FT6336U CTP Controller/FT6336U.cpp.o
In file included from .pio/libdeps/wt32-sc01/FT6336U CTP Controller/src/FT6336U.cpp:9:0:
.pio/libdeps/wt32-sc01/FT6336U CTP Controller/src/FT6336U.h:128:14: warning: extra tokens at end of #ifdef directive
 #ifdef ESP32 || ESP8266
              ^
.pio/libdeps/wt32-sc01/FT6336U CTP Controller/src/FT6336U.cpp:16:14: warning: extra tokens at end of #ifdef directive
 #ifdef ESP32 || ESP8266
              ^
.pio/libdeps/wt32-sc01/FT6336U CTP Controller/src/FT6336U.cpp:27:14: warning: extra tokens at end of #ifdef directive
 #ifdef ESP32 || ESP8266
              ^
.pio/libdeps/wt32-sc01/FT6336U CTP Controller/src/FT6336U.cpp: In member function 'uint8_t FT6336U::readByte(uint8_t)':
.pio/libdeps/wt32-sc01/FT6336U CTP Controller/src/FT6336U.cpp:258:12: warning: 'rdData' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return rdData; 
            ^

I believe #ifdef ESP32 || ESP8266 should be #if defined(ESP32) || defined(ESP8266). Would you like me to create a Pull Request for this change?

aselectroworks commented 3 years ago

Hi @fvanroie,

Thanks for notification. I misunderstanding about the operation of #ifdef. I already fixed this issue. Please pull it.

fvanroie commented 3 years ago

The #ifdef warnings are now indeed fixed. There is still one compiler warning remaining though:

 .pio/libdeps/m5stack-core2/FT6336U CTP Controller/src/FT6336U.cpp: In member function 'uint8_t FT6336U::readByte(uint8_t)':
.pio/libdeps/m5stack-core2/FT6336U CTP Controller/src/FT6336U.cpp:258:12: warning: 'rdData' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return rdData; 
            ^

Initializing the value uint8_t rdData = 0; fixes that one too.

We use the touch driver in our project and it is working great. Your work is much appreciated! Thank you for your fast response.

aselectroworks commented 3 years ago

Hi fvanroie,

Thank you for checking my code on pio. I fixed it.

fvanroie commented 3 years ago

All's good now. Great and thank you for creating this library.