'hw_timer_t' does not name a type error when in an included file

sorvad
Posts: 2
Joined: Sun Jun 14, 2020 7:33 am

'hw_timer_t' does not name a type error when in an included file

Postby sorvad » Sun Jun 14, 2020 7:48 am

This may be my inexperience but I'm getting a

'hw_timer_t' does not name a type error

when declared in an included file. I've stripped the problem down to very simple files. (All using the Arduino IDE for ESP32 Dev Module), if I have this simple file;

Code: Select all

hw_timer_t * timer = NULL;
void setup() {
}
void loop() {
}
Without any headers etc. then all compiles OK. If I have an included file with it in then fails with the mentioned error. These files below recreate the problem;

The Main

Code: Select all

#include "IncludedFile.h"
void setup() {
}
void loop() {
}
"IncludedFile.h"

Code: Select all

hw_timer_t * timer = NULL;
"IncludedFile.cpp"

Code: Select all

#include "IncludedFile.h"
Now if I take out the #include "IncludedFile.h" from #include "IncludedFile.cpp" then it compiles but then I don't have access to the variable "timer".

I know I'm doing something basic wrong here but what, help appreciated :)

idahowalker
Posts: 166
Joined: Wed Aug 01, 2018 12:06 pm

Re: 'hw_timer_t' does not name a type error when in an included file

Postby idahowalker » Sun Jun 14, 2020 9:12 am

In this thread I posted code that uses the hardware timer and other libraries https://esp32.com/viewtopic.php?f=19&t=16109

sorvad
Posts: 2
Joined: Sun Jun 14, 2020 7:33 am

Re: 'hw_timer_t' does not name a type error when in an included file

Postby sorvad » Sun Jun 14, 2020 10:23 am

Thanks for that, appreciate you took the time to reply. Your example uses a timer in the main file like my first example above. I can get this to work fine and I've written esp32 timer interrupt code for other projects but the code has always been in the main file. Today I thought I'd keep things a bit tidy and on my latest project I decided to move the code that deals with the interrupts into a separate file that I include and that's when I got the error. I managed to strip it right down to the minimum to repeat the issue, which is what you see in my post.

So it's not quite what I'm looking for but again thanks for replying :)

Who is online

Users browsing this forum: No registered users and 67 guests