Strange build error: /main.c:69:77: error: implicit declaration of function 'esp_err_to_name'

yanosz
Posts: 12
Joined: Sun Jun 10, 2018 12:37 pm

Strange build error: /main.c:69:77: error: implicit declaration of function 'esp_err_to_name'

Postby yanosz » Sun Jun 10, 2018 12:47 pm

Hello folks,

when trying to compile: https://github.com/FieldTracks/JellingStone - I got a very strange error message

Code: Select all

C build/main/main.o
In file included from /home/esp32/esp-idf/components/bt/bluedroid/include/bt_trace.h:26:0,
                 from /home/esp32/esp-idf/components/bt/bluedroid/include/bt_target.h:1834,
                 from /home/esp32/esp-idf/components/bt/bluedroid/device/include/controller.h:25,
                 from /home/esp32/JellingStone/main/./main.c:23:
/home/esp32/JellingStone/main/./main.c: In function 'init':
/home/esp32/JellingStone/main/./main.c:69:77: error: implicit declaration of function 'esp_err_to_name' [-Werror=implicit-function-declaration]
         ESP_LOGE(MY_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret));
                                                                             ^
/home/esp32/esp-idf/components/log/include/esp_log.h:242:168: note: in definition of macro 'ESP_LOGE'
 (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR)   { esp_log_write(ESP_LOG_ERROR,   tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__
                                                                                                                               ^
/home/esp32/esp-idf/components/log/include/esp_log.h:203:27: error: format '%s' expects argument of type 'char *', but argument 7 has type 'int' [-Werror=format=]
 #define LOG_COLOR(COLOR)  "\033[0;" COLOR "m"
                           ^
/home/esp32/esp-idf/components/log/include/esp_log.h:206:27: note: in expansion of macro 'LOG_COLOR'
 #define LOG_COLOR_E       LOG_COLOR(LOG_COLOR_RED)
                           ^
/home/esp32/esp-idf/components/log/include/esp_log.h:220:37: note: in expansion of macro 'LOG_COLOR_E'
 #define LOG_FORMAT(letter, format)  LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n"
                                     ^
/home/esp32/esp-idf/components/log/include/esp_log.h:242:117: note: in expansion of macro 'LOG_FORMAT'
 #define ESP_LOGE( tag, format, ... )  if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR)   { esp_log_write(ESP_LOG_ERROR,   tag, LOG_FORMAT(E, format)
                                                                                                                     ^
/home/esp32/JellingStone/main/./main.c:69:9: note: in expansion of macro 'ESP_LOGE'
         ESP_LOGE(MY_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret));
         ^
/home/esp32/esp-idf/components/log/include/esp_log.h:203:27: error: format '%s' expects argument of type 'char *', but argument 7 has type 'int' [-Werror=format=]
 #define LOG_COLOR(COLOR)  "\033[0;" COLOR "m"
                           ^
/home/esp32/esp-idf/components/log/include/esp_log.h:206:27: note: in expansion of macro 'LOG_COLOR'
 #define LOG_COLOR_E       LOG_COLOR(LOG_COLOR_RED)
                           ^
/home/esp32/esp-idf/components/log/include/esp_log.h:220:37: note: in expansion of macro 'LOG_COLOR_E'
 #define LOG_FORMAT(letter, format)  LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n"
                                     ^
/home/esp32/esp-idf/components/log/include/esp_log.h:242:117: note: in expansion of macro 'LOG_FORMAT'
 #define ESP_LOGE( tag, format, ... )  if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR)   { esp_log_write(ESP_LOG_ERROR,   tag, LOG_FORMAT(E, format)
                                                                                                                     ^
/home/esp32/JellingStone/main/./main.c:74:9: note: in expansion of macro 'ESP_LOGE'
         ESP_LOGE(MY_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret));
         ^
/home/esp32/esp-idf/components/log/include/esp_log.h:203:27: error: format '%s' expects argument of type 'char *', but argument 7 has type 'int' [-Werror=format=]
 #define LOG_COLOR(COLOR)  "\033[0;" COLOR "m"
                           ^
/home/esp32/esp-idf/components/log/include/esp_log.h:206:27: note: in expansion of macro 'LOG_COLOR'
 #define LOG_COLOR_E       LOG_COLOR(LOG_COLOR_RED)
                           ^
/home/esp32/esp-idf/components/log/include/esp_log.h:220:37: note: in expansion of macro 'LOG_COLOR_E'
 #define LOG_FORMAT(letter, format)  LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n"
                                     ^
/home/esp32/esp-idf/components/log/include/esp_log.h:242:117: note: in expansion of macro 'LOG_FORMAT'
 #define ESP_LOGE( tag, format, ... )  if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR)   { esp_log_write(ESP_LOG_ERROR,   tag, LOG_FORMAT(E, format)
                                                                                                                     ^
/home/esp32/JellingStone/main/./main.c:79:9: note: in expansion of macro 'ESP_LOGE'
         ESP_LOGE(MY_TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
         ^
/home/esp32/esp-idf/components/log/include/esp_log.h:203:27: error: format '%s' expects argument of type 'char *', but argument 7 has type 'int' [-Werror=format=]
 #define LOG_COLOR(COLOR)  "\033[0;" COLOR "m"
                           ^
/home/esp32/esp-idf/components/log/include/esp_log.h:206:27: note: in expansion of macro 'LOG_COLOR'
 #define LOG_COLOR_E       LOG_COLOR(LOG_COLOR_RED)
                           ^
/home/esp32/esp-idf/components/log/include/esp_log.h:220:37: note: in expansion of macro 'LOG_COLOR_E'
 #define LOG_FORMAT(letter, format)  LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n"
                                     ^
/home/esp32/esp-idf/components/log/include/esp_log.h:242:117: note: in expansion of macro 'LOG_FORMAT'
 #define ESP_LOGE( tag, format, ... )  if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR)   { esp_log_write(ESP_LOG_ERROR,   tag, LOG_FORMAT(E, format)
                                                                                                                     ^
/home/esp32/JellingStone/main/./main.c:84:9: note: in expansion of macro 'ESP_LOGE'
         ESP_LOGE(MY_TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
         ^
cc1: some warnings being treated as errors
/home/esp32/esp-idf/make/component_wrapper.mk:273: recipe for target 'main.o' failed
make[1]: *** [main.o] Error 1
/home/esp32/esp-idf/make/project.mk:450: recipe for target 'component-main-build' failed
make: *** [component-main-build] Error 2

System is: Debian Strecht, gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1), esp idf is: release/v3.0 (commit c2b39f4a5f4234d3276bec40d42132589739d655, Jun 1 2018) - the project uses https://github.com/tuanpmt/espmqtt.git

It looks like, the system has issue parsing esp_log.h - however, I can compile the example without any problems.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Strange build error: /main.c:69:77: error: implicit declaration of function 'esp_err_to_name'

Postby ESP_Angus » Mon Jun 11, 2018 12:31 am

Hi yanosz,
yanosz wrote:

Code: Select all

/home/esp32/JellingStone/main/./main.c:69:77: error: implicit declaration of function 'esp_err_to_name' [-Werror=implicit-function-declaration]
The esp_err_to_name() function was added to esp_err.h after IDF v3.0 was released. It's new in v3.1. You can solve this error by switching to the master IDF branch, or rewriting the log lines in main.c so they don't call esp_err_to_name() (ie log the error as a number).
yanosz wrote: It looks like, the system has issue parsing esp_log.h - however, I can compile the example without any problems.
One of the irritating things about C preprocessor macros is that if there's an error in an expanded macro (worse, in recursively expanded macros), the compiler can't tell exactly where this comes from - so it tells you a story about "I got this error here, while I was expanding this, while I was exapdning that ...". In this case, the initial error is inside a log macro so the compiler takes you down this complex trace of what it was expanding - even though the error isn't actually introduced by anything inside esp_log.h.

A tip that's served me well with compiler error messages is to read the first error line, and not even keep reading until I'm sure the first line isn't the problem. :)

yanosz
Posts: 12
Joined: Sun Jun 10, 2018 12:37 pm

[solved ]Re: Strange build error: /main.c:69:77: error: implicit declaration of function 'esp_err_to_name'

Postby yanosz » Tue Jun 12, 2018 9:20 am

Thanks, works like a charm!

Who is online

Users browsing this forum: Baidu [Spider], kammutierspule and 132 guests