Irremoteesp8266: unknown type name 'IRsend'

Created on 11 Aug 2017  路  5Comments  路  Source: crankyoldgit/IRremoteESP8266

In the C file in simplesample_mqtt.c, which connects Arduino to the Azure IoT hub, I need to use the IRsend and IrRemoteESP8266 libraries to send an infrared signal with Azure IoT hub.

  1. #include <IRremoteESP8266.h>
  2. #include <IRsend.h>
  3. IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)

I don't have any problem when I use this code in my main Ardunio file. But when I use these includes in a C file (implesample_mqtt.c), I get this error from line 3: "unknown type name 'IRsend'".

enter image description here

error full info :
Arduino: 1.8.2 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200, 4M (3M SPIFFS)"

In file included from sketchsimplesample_mqtt.c:29:0:

C:Program Files (x86)ArduinolibrariesIRremoteESP8266src/IRsend.h:29:1: error: unknown type name 'class'

class IRsend {

C:Program Files (x86)ArduinolibrariesIRremoteESP8266src/IRsend.h:29:14: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token

class IRsend {

simplesample_mqtt.c:31: error: unknown type name 'IRsend'

IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)

simplesample_mqtt.c:31: error: expected declaration specifiers or '...' before numeric constant

IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)

exit status 1
unknown type name 'IRsend'

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

Most helpful comment

Oh wait, I think it _may be_ because it's a C file, not a C++ file.

You should probably be modifying https://github.com/Azure/azure-iot-arduino/blob/master/examples/simplesample_http/simplesample_http.ino not https://github.com/Azure/azure-iot-arduino/blob/master/examples/simplesample_http/simplesample_http.c

I don't think C has the concept of classes. *.c files mean C, *.cpp/*.ino/etc mean C++/normal arduino.

All 5 comments

Frankly, I'm confused. That's not expected as you seem to have coded it correctly from what limited info I can see in the screenshot. Can you share/host your code somewhere so I can download it and try it myself?
The only suggestions I can make before that is to make sure you're using the latest release of the library and esp8266 board library. e.g. Go into the arduino library manager and check it's using 2.1.1 of IRremoteESP8266 and in the Board Manager, that it's using 2.3.0 of the ESP8266 config.

Oh wait, I think it _may be_ because it's a C file, not a C++ file.

You should probably be modifying https://github.com/Azure/azure-iot-arduino/blob/master/examples/simplesample_http/simplesample_http.ino not https://github.com/Azure/azure-iot-arduino/blob/master/examples/simplesample_http/simplesample_http.c

I don't think C has the concept of classes. *.c files mean C, *.cpp/*.ino/etc mean C++/normal arduino.

Did you have any luck?

Go to Sketch -> include library -> manage libraries in your arduino IDE and search for IRremoteESP8266 and install it properly...
Then restart your IDE ... Then try the codes which is in the examples ........!!
You may be have a luck !!
Have a great day

@crankyoldgit thanks for the tips . its worked for me .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlhavens picture jlhavens  路  7Comments

wizkidorg picture wizkidorg  路  7Comments

the-mentor picture the-mentor  路  5Comments

crankyoldgit picture crankyoldgit  路  3Comments

scudrunner picture scudrunner  路  7Comments