CptnKrunch
CptnKrunch

Reputation: 121

Trying to include httpclient.h inside ldebug.c is causing an error during compilation

My goal is to do an http post request inside ldebug.c by including httpclient. It worked in dbg_printf.c but I'm getting compilation errors in ldebug.c.

In file included from ../ldebug.c:28:0:
../../http/httpclient.h:69:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'http_request'
 void ICACHE_FLASH_ATTR http_request(const char * url, const char * method, const char * headers, const char * post_data, http_callback_t callback_handle, int redirect_follow_count);

Is there another way I can do a post request?

Upvotes: 0

Views: 113

Answers (1)

romkey
romkey

Reputation: 7069

ICACHE_FLASH_ATTR is a macro defined in the file c_types.h

There are two reasons that it wouldn't be defined.

First, ldebug.c may not include c_types.h or include a file which #includes c_types.h. This is easy to fix - edit ldebug.c and add

#include <c_types.h>

before #include <httpclient.h>

The other possibility is that the symbol ICACHE_FLASH is not defined when ldebug.c gets compiled. The file c_types.h only defines ICACHE_FLASH_ATTR if ICACHE_FLASH is #define'd. If the first fix doesn't work, you'll need to make sure that you #define ICACHE_FLASH when you compile ldebug.c

The easiest way to do this is to add

#define ICACHE_FLASH 1

as the very first line of ldebug.c

Or you can make sure that you set -DICACHE_FLASH=1 as a compiler flag in whatever your development environment is. Changing ldebug.c is almost certainly the easier way to do this.

Upvotes: 1

Related Questions