# IDE mistakes JavaScript function for type

**URL:** <https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022>\
**Category:** Programming\
**Created:** [January 29, 2022, 8:54pm UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022 "2022-01-29T20:54:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![javamakesmybloodboil](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/javamakesmybloodboil/32/733544_2.png) [@javamakesmybloodboil](https://forum.arduino.cc/u/javamakesmybloodboil)\
**Post date:** [January 29, 2022, 8:54pm UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/1 "2022-01-29T20:54:08Z")

</div>

Maybe my eye is skipping over something but it looks like the IDE thinks that the functions are types. I don't really want to put the HTML into a separate file, so I have no idea how to work around this. Any tip is greatly appreciated.

```cpp
/ *********
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com
********* /

// Import required libraries
#include <WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>

// Data wire is connected to GPIO 4
#define ONE_WIRE_BUS 32

                                                                                            //TO DO LIST
//values for controlling temperatures
//controlling the relays
bool Relay1Status = LOW;
uint8_t Relay1Pin = 13;
//input from the web interface
int TargetTemp = 0;
String TargetTempStr = String(TargetTemp);
int MinTemp = TargetTemp - 1;
int MaxTemp = TargetTemp + 1;
//404 if server can't respond
void notFound(AsyncWebServerRequest *request) {
  request->send(404, "text/plain", "Not found");
}

                                                                                //Assingning values and setting up 

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);

// Variables to store temperature values
String temperatureF = "";
String temperatureC = "";
int TempNum;
// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 3000;

// Replace with your network credentials
const char* ssid = "Telekom-d86e0e-2.4GHz";
const char* password = "KH9HENFUETJ5";

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

                                                                               

                                                                               //Reading DS18B20 Temperature

String readDSTemperatureC() {
  // Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);

  if (tempC == -127.00) {
    Serial.println("Failed to read from DS18B20 sensor");
    return "--";
  } else {
    Serial.print("Temperature Celsius: ");
    Serial.println(tempC);
  }
  return String(tempC);
}

String readDSTemperatureF() {
  // Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
  sensors.requestTemperatures();
  float tempF = sensors.getTempFByIndex(0);

  if (int(tempF) == -196) {
    Serial.println("Failed to read from DS18B20 sensor");
    return "--";
  } else {
    Serial.print("Temperature Fahrenheit: ");
    Serial.println(tempF);
  }
  return String(tempF);
}

                                                                                
                                                                                
                                                                                //HTML page

const char index_html[] PROGMEM = R"rawliteral(
    <!DOCTYPE HTML><html>
    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
      <style>
        html {
         font-family: Arial;
         display: inline-block;
         margin: 0px auto;
         text-align: center;
        }
        h2 { font-size: 3.0rem; }
        p { font-size: 3.0rem; }
        .units { font-size: 1.2rem; }
        .ds-labels{
          font-size: 1.5rem;
          vertical-align:middle;
          padding-bottom: 15px;
        }
      </style>
    </head>
    <body>
      <h2>ESP DS18B20 Server</h2>
      <p>
        <i class="fas fa-thermometer-half" style="color:#059e8a;"></i> 
        <span class="ds-labels">Temperature Celsius</span> 
        <span id="temperaturec">%TEMPERATUREC%</span>
        <sup class="units">&deg;C</sup>
      </p>
      <p>
        <h3> Target Temperature </h3>
        <i class="fas fa-thermometer-half" style="color:#059e8a;"></i> 
        <span class="ds-labels"></span> 
        <span id="TargetTemp">%TARGETTEMPERATURE%</span>
        <sup class="units">&deg;C</sup>
        
        <button class = "addingButton" onclick = addToInt()"> + </button>
        <button class = "subtractingButton" onclick = subFromInt()"> + </button>
      </p>    
    </body>
    <script>
      setInterval(function ( ) {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            document.getElementById("temperaturec").innerHTML = this.responseText;
          }
        };
        xhttp.open("GET", "/temperaturec", true);
        xhttp.send();
      }, 10000) ;
                      
      setInterval(function ( ) {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            document.getElementById("TargetTemp").innerHTML = this.responseText;
          }
        };
        xhttp.open("GET", "/TargetTemp", true);
        xhttp.send();
      }, 10000) ;
      
       function addToInt(){
          var xhr = new XMLHttpRequest();
          xhr.open("GET", "/add", true);
          xhr.send();
       }
       function subFromInt(){
          var xhr = new XMLHttpRequest();
          xhr.open("GET", "/subtract", true);
          xhr.send();
       }
    </script>
    </html>)rawliteral";

// Replaces placeholder with DS18B20 values
String processor(const String& var) {
  //Serial.println(var);
  if (var == "TEMPERATUREC") {
    return temperatureC;                                                        
  }
  else if (var == "TEMPERATUREF") {
    return temperatureF;
  }
   if (var == "TARGETTEMPERATURE") {
    return String(TargetTemp);                                                        
  }
  return String();
}

void setup() {
  pinMode(13,OUTPUT);
  // Serial port for debugging purposes
  Serial.begin(115200);
  Serial.println();

  // Start up the DS18B20 library
  sensors.begin();

  temperatureC = readDSTemperatureC();
  temperatureF = readDSTemperatureF();

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  Serial.println("Connecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  // Print ESP Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/html", index_html, processor);
  });
  server.on("/temperaturec", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", temperatureC.c_str());
  });
  server.on("/TargetTemp", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", TargetTempStr.c_str());                                             
  });
      // Start server
  server.begin();

  server.on("/add", HTTP_GET, [](AsyncWebServerRequest * request) {
    TargetTemp++;
    request->send(200, "text/plain", "ok");
  });
  server.on("/subtract", HTTP_GET, [](AsyncWebServerRequest * request) {
    TargetTemp--;
    request->send(200, "text/plain", "ok");
  });

});
}
void loop() {
  if ((millis() - lastTime) > timerDelay) {
    temperatureC = readDSTemperatureC();
    temperatureF = readDSTemperatureF();
    lastTime = millis();
  }
  TempNum = readDSTemperatureC().toInt();
  if (TempNum > MaxTemp) {
    digitalWrite(13, LOW);
  }
  if (MinTemp > TempNum) {
    digitalWrite(13, HIGH);
  }
  Serial.println(TempNum);
  delay(1000);
}
```

Arduino: 1.8.17 Hourly Build 2021/09/06 02:33 (Windows 10), Board: "NodeMCU-32S, 80MHz, 921600"

sketch\_dec23a:158:1: error: 'function' does not name a type

```
    function addToInt(){

```

^

sketch\_dec23a:163:1: error: 'function' does not name a type

```
    function subFromInt(){

```

^

sketch\_dec23a:235:2: error: expected unqualified-id before ')' token

});

^

sketch\_dec23a:236:1: error: expected declaration before '}' token

}

^

Multiple libraries were found for "WiFi.h"

Used: C:\Users\hunya\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi

Not used: C:\Users\hunya\Documents,\Arduino\arduino-nightly\libraries\WiFi

Multiple libraries were found for "AsyncTCP.h"

Used: C:\Users\hunya\Documents\Arduino\libraries\AsyncTCP

Not used: C:\Users\hunya\Documents,\Arduino\arduino-nightly\libraries\AsyncTCP

Multiple libraries were found for "ESPAsyncWebServer.h"

Used: C:\Users\hunya\Documents,\Arduino\arduino-nightly\libraries\ESPAsyncWebServer

Not used: C:\Users\hunya\Documents\Arduino\libraries\ESPAsyncWebServer-master

exit status 1

'function' does not name a type

This report would have more information with  
"Show verbose output during compilation"  
option enabled in File -\> Preferences.

---

<div class="post-metadata">

**Author:** ![killzone\_kid](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/killzone_kid/32/1098074_2.png) [@killzone\_kid](https://forum.arduino.cc/u/killzone_kid)\
**Post date:** [January 29, 2022, 9:34pm UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/2 "2022-01-29T21:34:34Z")

</div>

Runs fine [sketch.ino - Wokwi Arduino and ESP32 Simulator](https://wokwi.com/arduino/projects/322157204262093395)

---

<div class="post-metadata">

**Author:** ![westfw](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/westfw/32/213443_2.png) [@westfw](https://forum.arduino.cc/u/westfw)\
**Post date:** [January 30, 2022, 12:59am UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/3 "2022-01-30T00:59:00Z")

</div>

I vaguely suspect that the Arduino pre-processing doesn't know about raw string literals, and things blow up when it generates prototypes for what it THINKS are functions inside the string.

Putting the literal in a separate .h file seems like an easy solution.

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [January 30, 2022, 3:44am UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/4 "2022-01-30T03:44:45Z")

</div>

I distilled it down to this minimal demo:

```cpp
void foo() {}
const char someRawString[] = R"rawliteral(
    ";
    notArduinoType notArduinoFunction() {}
  )rawliteral";
void setup() {}
void loop() {}

```

After [sketch preprocessing](https://arduino.github.io/arduino-cli/latest/sketch-build-process/#pre-processing), the code looks like this:

```cpp
#include <Arduino.h>
#line 1 "C:\\Users\\asdf\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2022029-6972-afm1mj.bko1\\sketch_jan29a\\sketch_jan29a.ino"
#line 1 "C:\\Users\\asdf\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2022029-6972-afm1mj.bko1\\sketch_jan29a\\sketch_jan29a.ino"
void foo();
#line 4 "C:\\Users\\asdf\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2022029-6972-afm1mj.bko1\\sketch_jan29a\\sketch_jan29a.ino"
notArduinoType notArduinoFunction();
#line 1 "C:\\Users\\asdf\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2022029-6972-afm1mj.bko1\\sketch_jan29a\\sketch_jan29a.ino"
void foo() {}
const char someRawString[] = R"rawliteral(
    ";
    notArduinoType notArduinoFunction() {}
  )rawliteral";
void setup() {}
void loop() {}

```

So as **westfw** hypothesized, the sketch preprocessor generated a function prototype for the things resembling a C++ function from the raw string literal.

* * *

There are some previous mentions of sketch preprocessor misbehaving in sketches that have specific raw string literal content here:

> [@Exit status 1 was not declared in this scope. error message](https://forum.arduino.cc/t/exit-status-1-was-not-declared-in-this-scope-error-message/632717/7):
>
> Here's a minimal demonstration of the bug: char foo[] = R"=( " )="; void setup() { &nbsp;bar(); } void loop() {} void bar(){} RawStringLiteralBug:5:7: error: 'bar' was not declared in this scope &nbsp; bar(); &nbsp; &nbsp; &nbsp; ^ The preprocessed sketch: #include \<Arduino.h\> #line 1 "E:\\arduino\\RawStringLiteralBug\\RawStringLiteralBug.ino" char foo[] = R"=( " )="; void setup() { &nbsp;bar(); } void loop() {} void bar(){} Note none of the prototypes were generated. This is the same problem that happened in brow…

and here:

> <https://github.com/arduino/arduino-cli/issues/1191>
>
> Please see https://forum.arduino.cc/t/including-javascript-in-a-webpage-served-b…y-espasyncwebserver/697109 where the issue was raised
> 
> Source code:
> \`\`\`cpp
> const char index\_html\[\] PROGMEM = R"rawliteral(
> \<!DOCTYPE HTML\>\<html\>
> \<head\>
> \<meta name="viewport" content="width=device-width, initial-scale=1"\>
> \<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"\>
> \<style\>
> html {
> font-family: Arial;
> display: inline-block;
> margin: 0px auto;
> text-align: center;
> }
> h2 { font-size: 3.0rem; }
> p { font-size: 3.0rem; }
> .units { font-size: 1.2rem; }
> .dht-labels{
> font-size: 1.5rem;
> vertical-align:middle;
> padding-bottom: 15px;
> }
> \</style\>
> \<script\>
> var count=10;
> var counter=setInterval(timerjs, 1000); //1000 will run it every 1 second
> function timerjs()
> {
> count=count-1;
> if (count \<= 0)
> {
> clearInterval(counter);
> return;
> }
> 
> document.getElementById("timerjs").innerHTML=count + " secs"; // watch for spelling
> }
> \</script\>
> \</head\>
> \<body\>
> \<h2\>Remote 1 temperature & humidity\</h2\>
> \<p\>
> \<i class="fas fa-thermometer-half" style="color:#059e8a;"\>\</i\>
> \<span class="dht-labels"\>Temperature\</span\>
> \<span id="temperature"\>%TEMPERATURE%\</span\>
> \<sup class="units"\>&deg;C\</sup\>
> \</p\>
> \<p\>
> \<i class="fas fa-tint" style="color:#00add6;"\>\</i\>
> \<span class="dht-labels"\>Humidity\</span\>
> \<span id="humidity"\>%HUMIDITY%\</span\>
> \<sup class="units"\>%\</sup\>
> \</p\>
> \<p\>
> Time to next sample: \<span id="timerjs"\>\</span\>
> \</p\>
> \</body\>
> \<script\>
> setInterval(function ( ) {
> var xhttp = new XMLHttpRequest();
> xhttp.onreadystatechange = function() {
> if (this.readyState == 4 && this.status == 200) {
> document.getElementById("temperature").innerHTML = this.responseText;
> }
> };
> xhttp.open("GET", "/temperature", true);
> xhttp.send();
> }, 10000 ) ;
> 
> setInterval(function ( ) {
> var xhttp = new XMLHttpRequest();
> xhttp.onreadystatechange = function() {
> if (this.readyState == 4 && this.status == 200) {
> document.getElementById("humidity").innerHTML = this.responseText;
> }
> };
> xhttp.open("GET", "/humidity", true);
> xhttp.send();
> }, 10000 ) ;
> \</script\>
> \</html\>)rawliteral";
> 
> void setup()
> {
> 
> }
> 
> void loop()
> {
> 
> }
> \`\`\`
> 
> Content of C:\\Users\\sterretje\\AppData\\Local\\Temp\\arduino\_build\_600637\\sketch\\sketch\_feb22a.ino.cpp 
> \`\`\`cpp
> \#include \<Arduino.h\>
> \#line 1 "C:\\\\Users\\\\sterretje\\\\AppData\\\\Local\\\\Temp\\\\arduino\_modified\_sketch\_915464\\\\sketch\_feb22a.ino"
> \#line 1 "C:\\\\Users\\\\sterretje\\\\AppData\\\\Local\\\\Temp\\\\arduino\_modified\_sketch\_915464\\\\sketch\_feb22a.ino"
> 
> const char index\_html\[\] PROGMEM = R"rawliteral(
> \<!DOCTYPE HTML\>\<html\>
> \<head\>
> \<meta name="viewport" content="width=device-width, initial-scale=1"\>
> \<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"\>
> \<style\>
> html {
> font-family: Arial;
> display: inline-block;
> margin: 0px auto;
> text-align: center;
> }
> h2 { font-size: 3.0rem; }
> p { font-size: 3.0rem; }
> .units { font-size: 1.2rem; }
> .dht-labels{
> font-size: 1.5rem;
> vertical-align:middle;
> padding-bottom: 15px;
> }
> \</style\>
> \<script\>
> var count=10;
> 
> var counter=setInterval(timerjs, 1000); //1000 will run it every 1 second
> \#line 27 "C:\\\\Users\\\\sterretje\\\\AppData\\\\Local\\\\Temp\\\\arduino\_modified\_sketch\_915464\\\\sketch\_feb22a.ino"
> function timerjs();
> \#line 27 "C:\\\\Users\\\\sterretje\\\\AppData\\\\Local\\\\Temp\\\\arduino\_modified\_sketch\_915464\\\\sketch\_feb22a.ino"
> function timerjs()
> {
> count=count-1;
> if (count \<= 0)
> {
> clearInterval(counter);
> return;
> }
> 
> document.getElementById("timerjs").innerHTML=count + " secs"; // watch for spelling
> }
> \</script\>
> \</head\>
> \<body\>
> \<h2\>Remote 1 temperature & humidity\</h2\>
> \<p\>
> \<i class="fas fa-thermometer-half" style="color:#059e8a;"\>\</i\>
> \<span class="dht-labels"\>Temperature\</span\>
> \<span id="temperature"\>%TEMPERATURE%\</span\>
> \<sup class="units"\>&deg;C\</sup\>
> \</p\>
> \<p\>
> \<i class="fas fa-tint" style="color:#00add6;"\>\</i\>
> \<span class="dht-labels"\>Humidity\</span\>
> \<span id="humidity"\>%HUMIDITY%\</span\>
> \<sup class="units"\>%\</sup\>
> \</p\>
> \<p\>
> Time to next sample: \<span id="timerjs"\>\</span\>
> \</p\>
> \</body\>
> \<script\>
> setInterval(function ( ) {
> var xhttp = new XMLHttpRequest();
> xhttp.onreadystatechange = function() {
> if (this.readyState == 4 && this.status == 200) {
> document.getElementById("temperature").innerHTML = this.responseText;
> }
> };
> xhttp.open("GET", "/temperature", true);
> xhttp.send();
> }, 10000 ) ;
> 
> setInterval(function ( ) {
> var xhttp = new XMLHttpRequest();
> xhttp.onreadystatechange = function() {
> if (this.readyState == 4 && this.status == 200) {
> document.getElementById("humidity").innerHTML = this.responseText;
> }
> };
> xhttp.open("GET", "/humidity", true);
> xhttp.send();
> }, 10000 ) ;
> \</script\>
> \</html\>)rawliteral";
> 
> void setup()
> {
> 
> }
> 
> void loop()
> {
> 
> }
> \`\`\`
> Please note the including of \`#line\` in the output that does not exist in the ino file
> 
> \### Additional context
> 
> \#### Additional reports
> 
> \- https://forum.arduino.cc/t/line-driving-me-crazy/1180650
> 
> \#### Related
> 
> \- https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022
> \- https://forum.arduino.cc/t/c-super-quotes-compiler-bug/990071

Note the comment from the developer there:

> It's `ctags` that is not able to correctly parse multil-line raw literals.  
> It's unlikely that this will be fixed upstream (at least not soon).
> 
> A workaround may be to put the strings inside a .h file (that is not preprocessed) and include it from the main .ino.

---

<div class="post-metadata">

**Author:** ![killzone\_kid](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/killzone_kid/32/1098074_2.png) [@killzone\_kid](https://forum.arduino.cc/u/killzone_kid)\
**Post date:** [January 30, 2022, 9:44am UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/5 "2022-01-30T09:44:35Z")

</div>

> [@westfw](#):
>
> I vaguely suspect that the Arduino pre-processing doesn't know about raw string literals

It knows, I successfully used it with MKR WiFi to output html page

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [January 30, 2022, 10:23am UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/6 "2022-01-30T10:23:00Z")

</div>

The bug only happens under specific conditions. For example, this one compiled successfully:

> [@killzone\_kid](#):
>
> Runs fine [sketch.ino - Wokwi Arduino and ESP32 Simulator](https://wokwi.com/arduino/projects/322157204262093395)

But add a function definition above the raw string declaration, and you will see the error reported by **javamakesmybloodboil** :  
[https://wokwi.com/arduino/projects/322205654555034195](https://wokwi.com/arduino/projects/322205654555034195)

---

<div class="post-metadata">

**Author:** ![killzone\_kid](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/killzone_kid/32/1098074_2.png) [@killzone\_kid](https://forum.arduino.cc/u/killzone_kid)\
**Post date:** [January 30, 2022, 12:15pm UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/7 "2022-01-30T12:15:41Z")

</div>

Try adding

```cpp
void notFound(AsyncWebServerRequest *request);
String readDSTemperatureC();
String readDSTemperatureF();

```

At the top of the sketch

---

<div class="post-metadata">

**Author:** ![6v6gt](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/6v6gt/32/225488_2.png) [@6v6gt](https://forum.arduino.cc/u/6v6gt)\
**Post date:** [January 30, 2022, 12:24pm UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/8 "2022-01-30T12:24:55Z")

</div>

That automatic prototype generation probably sounded like a nice newbie-friendly feature when it was first dreamed up but has had far reaching consequences and is a perfect example of the risks of altering language features.

Fortunately, its behaviour is restricted to .ino files. Of course, you can get around this by restructuring the sketch and moving stuff out of the ino file. That is once you understand what has happened and, hopefully, before too much agonising troubleshooting.

---

<div class="post-metadata">

**Author:** ![johnwasser](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnwasser/32/214270_2.png) [@johnwasser](https://forum.arduino.cc/u/johnwasser)\
**Post date:** [January 30, 2022, 7:11pm UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/9 "2022-01-30T19:11:13Z")

</div>

Another way to work around this problem with the Arduino automatic prototype generation is to put:  
`typedef void function;`  
at the top of the source code. Then the two prototypes that look like:

```cpp
  function addToInt();
  function subFromInt();

```

will know that the 'function' type is the same as 'void'.

This example compiles without error:

```cpp
typedef void function;

void foo() {}

const char someRawString[] = R"rawliteral(";
  function addToInt() {}
  function subFromInt() {}
")rawliteral";
 
void setup() {}
void loop() {}
```

---

<div class="post-metadata">

**Author:** ![killzone\_kid](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/killzone_kid/32/1098074_2.png) [@killzone\_kid](https://forum.arduino.cc/u/killzone_kid)\
**Post date:** [January 30, 2022, 7:31pm UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/10 "2022-01-30T19:31:09Z")

</div>

edit: it works but the code example does not (not with visual macro)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [July 29, 2022, 7:31pm UTC](https://forum.arduino.cc/t/ide-mistakes-javascript-function-for-type/953022/11 "2022-07-29T19:31:29Z")

</div>

Closed on July 29, 2022, 7:31pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
