0

This piece of code used to be compiled with no errors few months ago. I lost the VM image so I setup a new linux VM with latest GCC and libraries. But now I get these errors and warnings.

In file included from /opt/Espressif/ESP8266_SDK/include/ets_sys.h:12:0,
                 from include/espmissingincludes.h:4,
                 from driver/i2c.c:20:
driver/i2c.c: In function 'i2c_init':
/opt/Espressif/ESP8266_SDK/include/eagle_soc.h:247:94: error: suggest parentheses around arithmetic in operand of '|' [-Werror=parentheses]
 #define PIN_FUNC_SELECT(PIN_NAME, FUNC)  do {WRITE_PERI_REG(PIN_NAME,READ_PERI_REG(PIN_NAME) & (~(PERIPHS_IO_MUX_FUNC<<PERIPHS_IO_MUX_FUNC_S)) |( (((FUNC&BIT2)<<2)|(FUNC&0x3))<<PERIPHS_IO_MUX_FUNC_S) );} while (0)
                                                                                              ^
/opt/Espressif/ESP8266_SDK/include/eagle_soc.h:50:87: note: in definition of macro 'WRITE_PERI_REG'
 #define WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) =(val)
                                                                                       ^
driver/i2c.c:64:5: note: in expansion of macro 'PIN_FUNC_SELECT'
     PIN_FUNC_SELECT(I2C_SDA_MUX, I2C_SDA_FUNC);
     ^
/opt/Espressif/ESP8266_SDK/include/eagle_soc.h:247:94: error: suggest parentheses around arithmetic in operand of '|' [-Werror=parentheses]
 #define PIN_FUNC_SELECT(PIN_NAME, FUNC)  do {WRITE_PERI_REG(PIN_NAME,READ_PERI_REG(PIN_NAME) & (~(PERIPHS_IO_MUX_FUNC<<PERIPHS_IO_MUX_FUNC_S)) |( (((FUNC&BIT2)<<2)|(FUNC&0x3))<<PERIPHS_IO_MUX_FUNC_S) );} while (0)
                                                                                              ^
/opt/Espressif/ESP8266_SDK/include/eagle_soc.h:50:87: note: in definition of macro 'WRITE_PERI_REG'
 #define WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) =(val)
                                                                                       ^
driver/i2c.c:65:5: note: in expansion of macro 'PIN_FUNC_SELECT'
     PIN_FUNC_SELECT(I2C_SCK_MUX, I2C_SCK_FUNC);
     ^
cc1: all warnings being treated as errors
make: *** [build/driver/i2c.o] Error 1

Does anyone know how to solve these?

Mohit Jain
  • 30,259
  • 8
  • 73
  • 100
  • It looks like you're compiling with `-Werror`, so warnings are causing the compile to fail. You should fix these warnings of course, but if you just want a "quick and dirty" build then take out `-Werror` switch. – Paul R Jul 08 '15 at 06:35

1 Answers1

2

You are treating warnings as errors, presumably by building using -Werror. The code should compile if you remove that flag, or add -Wno-error=parentheses.

However, if the code is yours (rather than in a 3rd party library as it appears to be) it would be worth fixing the underlying cause. You could fix it in the macro by adding parenthesis in the right places, but I think you'd be better served by making those macros real functions.

Michael Anderson
  • 70,661
  • 7
  • 134
  • 187
  • I used the flag but it still produces those error. :-( – Shahab Intezari Jul 08 '15 at 11:30
  • in this line "#define WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t) (val)" I changed (unit32_t)(val) to a number ( for example 34) and everything was fine and it compiled with no errors!!!! – Shahab Intezari Jul 08 '15 at 11:34