Hi!
I have my main code file "include_test.ino"
#include "core.c"
void setup() {
dht.setup(12, DHTesp::DHT22);
}
void loop() {
// put your main code here, to run repeatedly:
}
And my "core.c" file
#include "DHTesp.h"
DHTesp dht;
void temperature() {
TempAndHumidity dht22 = dht.getTempAndHumidity();
}
Code compilation errors on
AArduino: 1.8.9 (Mac OS X), Board: "FireBeetle-ESP8266, 80 MHz, 921600, 4M (3M SPIFFS)"
WARNING: library DHT_sensor_library_for_ESPx claims to run on (esp8266, esp32, arduino-esp32) architecture(s) and may be incompatible with your current board which runs on (firebeetle8266) architecture(s).
In file included from sketch/core.c:1:0:
/Users/nico/Documents/Arduino/libraries/DHT_sensor_library_for_ESPx/DHTesp.h:94:3: error: expected specifier-qualifier-list before 'inline'
inline bool isTooHot(float temp, float humidity) {return (temp > (humidity * m_tooHot_m + m_tooHot_b));}
^
/Users/nico/Documents/Arduino/libraries/DHT_sensor_library_for_ESPx/DHTesp.h:105:1: error: unknown type name 'class'
class DHTesp
^
/Users/nico/Documents/Arduino/libraries/DHT_sensor_library_for_ESPx/DHTesp.h:106:1: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
{
^
core.c:3:1: error: unknown type name 'DHTesp'
DHTesp dht;
^
sketch/core.c: In function 'temperature':
core.c:6:3: error: unknown type name 'TempAndHumidity'
TempAndHumidity dht22 = dht.getTempAndHumidity();
^
core.c:6:30: error: request for member 'getTempAndHumidity' in something not a structure or union
TempAndHumidity dht22 = dht.getTempAndHumidity();
^
exit status 1
unknown type name 'DHTesp'This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
But compilation works OK if I just set all the code at "include_test.ino"
#include "DHTesp.h"
DHTesp dht;
void temperature() {
TempAndHumidity dht22 = dht.getTempAndHumidity();
}
void setup() {
dht.setup(12, DHTesp::DHT22);
}
void loop() {
// put your main code here, to run repeatedly:
}
Is there any way to modularize my code to extract the temperature() function to another file?
Thanks.