Esp-idf: error: called object 'socket' is not a function or function pointer

Created on 5 Dec 2017  路  1Comment  路  Source: espressif/esp-idf

I updated the esp-idf to the latest version on master and now get this error.

error: called object 'socket' is not a function or function pointer
     socket = socket(PF_INET, SOCK_STREAM, 0);

I get this error on this line https://github.com/tuanpmt/esp-request/blob/master/esp_request.c#L65

The code worked and compiled when I was on commit e43ac33b7c592f6c9ffc45523f04719934e3ad68 (https://github.com/espressif/esp-idf/tree/e43ac33b7c592f6c9ffc45523f04719934e3ad68)

I think the error has something to do with this commit https://github.com/espressif/esp-idf/commit/1c0543fb17ec700d27eaad9c379407047e82eb61

Most helpful comment

The variable on the left side is called socket, and it shadows the name of socket function, causing this error.
The variable has to be renamed to something else, for example socket_fd.

Previously it worked because socket was defined as a macro taking arguments. So single occurrence of socket without argument list was not expanded, whereas socket( args...) was expanded into lwip_socket( args...) by the preprocessor.

>All comments

The variable on the left side is called socket, and it shadows the name of socket function, causing this error.
The variable has to be renamed to something else, for example socket_fd.

Previously it worked because socket was defined as a macro taking arguments. So single occurrence of socket without argument list was not expanded, whereas socket( args...) was expanded into lwip_socket( args...) by the preprocessor.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kylefelipe picture kylefelipe  路  3Comments

okasha55 picture okasha55  路  3Comments

jakkra picture jakkra  路  3Comments

bfriedkin picture bfriedkin  路  4Comments

me21 picture me21  路  3Comments