-->
Page 1 of 1

ESP8266 Web Server ERROR

PostPosted: Sat Apr 30, 2016 2:10 pm
by insense
Hi everybody!

I'm getting an error when I try this but I don't know why.

Code: Select allerror: 'function' does not name a type
'function' does not name a type


Code: Select all...

const char web_site[] PROGMEM = R"=====(

      <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
      function a(){ ... }

)=====";

...


Does anybody know why? Thanks in advance!

Re: ESP8266 Web Server ERROR

PostPosted: Sat Apr 30, 2016 2:17 pm
by martinayotte
Who give you this error ? The compiler ?
Strange ! It should not ! (especially that copy/paste your piece in my sketch does compile ...)
Maybe you should turn ON Verbose and show us more detail about it.

EDIT : Oh ! it fails if placed in my *.ino, but not if located in a separate *.h , so it is probably the IDE pre-parser that fail.
So, the workaround : place it in "webpage.h" and include it in your *.ino.

EDIT2 : Stupid IDE pre-parser !!! :ugeek:
The resulting *.cpp in tmp looks like :
Code: Select all#line 1 "MyAPServer.ino"



#include <Time.h>
#include <FS.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
#include "Adafruit_MCP23017.h"
#include <SFE_BMP180.h>
#include <ArduinoJson.h>
#include "html_pages.h"
#include "images.h"
#include "images2.h"
#include "Arduino.h"
function a();
void forceARP();
void Test_Parse(Print &p);
bool connectWifi(const char *ssid, const char *password);
void showIP(Print& p);
void showClient(Print& p);
void showChipID(Print& p);
void GetExternalIP(Print& p);
void TestHTTPS(Print& p);
void GetGooglePage(Print& p);
void scanI2C(Print&p);
void writeMCP4725(uint16_t output);
[...]

Re: ESP8266 Web Server ERROR

PostPosted: Sat Apr 30, 2016 2:27 pm
by insense
martinayotte wrote:it fails if placed in my *.ino, but not if located in a separate *.h , so it is probably the IDE pre-parser that fail


Works! Thanks!

Ahahahaha, interesting! :D