"struct name" does not name a type ESP32

hi im getting this error message, tried to look after solutions in this forum but none of them worked.I am declaring this gpio pins as the example sketch (GPIO/GPIO interrupt) in the IDE. i am working with an ESP32 devkit. all the code below is outside and before any functions(setup(), loop() etc.
code:

//GPIO declarations.
struct GPIO {
  const uint8_t PIN; // gpio pin assingment
  uint32_t timesAct;// how many times it has been triggered.
  bool state; //stores state.
};

GPIO btn1 = {34,0,false};
GPIO btn2 = {35,0,false};
GPIO btn3 = {32,0,false};
GPIO btn4 = {33,0,false};
GPIO ledW = {13,0,false};
GPIO ledG = {12,0,false};
GPIO ledY = {14,0,false};
GPIO ledR = {27,0,false};

GPIO is likely a define or something used by the core environment
➜ Change GPIO into tGPIO And it should work

1 Like

it worked thank you. 4 years into this, programming on avr, arduino, idf and pic and didn't realize something like that :slight_smile:
have a good weekend

Have fun!

1 Like

We don't see your error message!

We did, it’s in the title, and it’s solved.

When OP is saying -
"hi im getting this error message [...].", I am expecting to see the following error message that has been reported in the IDE.

test-1:17:1: error: 'GPIO' does not name a type
 GPIO btn1 = {34, 0, false};
 ^~~~

Traditionally, GPIO stands for "General Purpose IO". As it (GPIO with capital letters) has pre-defined meaning in the ESP32 Core/Environment (post #2), we may use gpio (with small letters) instead.

1 Like

yes i knew what GPIO stands for, thats why when i was declaring gpio pins i chose that name. i made the problem on my own xd. Also, thank you on your opinion about how to write a topic. it is the first time i open a discussion.
have a good weekend!

1 Like

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