Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event documentation misses semicolon ; after ESP_EVENT_DECLARE_BASE(EVENT_BASE) causing compile error when copy pasting (IDFGH-12098) #13156

Closed
3 tasks done
flyinggorilla opened this issue Feb 10, 2024 · 4 comments
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@flyinggorilla
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.1

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

What is the expected behavior?

it is just confusing when the documentation misses the semicolon.

What is the actual behavior?

compile error on subsequent statement

Steps to reproduce.

copy paste from documentation of
ESP_EVENT_DECLARE_BASE(EVENT_BASE)

Build or installation Logs.

No response

More Information.

No response

@flyinggorilla flyinggorilla added the Type: Bug bugs in IDF label Feb 10, 2024
@flyinggorilla
Copy link
Author

sorry, super simple fix. just add the semicolon to the examples of
ESP_EVENT_DECLARE_BASE(EVENT_BASE)

https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/gptimer.html?highlight=timer#gptimer-register-event-callbacks

@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 10, 2024
@github-actions github-actions bot changed the title event documentation misses semicolon ; after ESP_EVENT_DECLARE_BASE(EVENT_BASE) causing compile error when copy pasting event documentation misses semicolon ; after ESP_EVENT_DECLARE_BASE(EVENT_BASE) causing compile error when copy pasting (IDFGH-12098) Feb 10, 2024
@adokitkat
Copy link
Collaborator

Hi, can you point to which code example has this missing semicolon please? You can just copy-paste it here. Thank you.

@flyinggorilla
Copy link
Author

flyinggorilla commented Feb 12, 2024

https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/system/esp_event.html?highlight=event%20loop#declaring-and-defining-events

Declaring and Defining Events
As mentioned previously, events consist of two-part identifiers: the event base and the event ID. The event base identifies an independent group of events; the event ID identifies the event within that group. Think of the event base and event ID as a person's last name and first name, respectively. A last name identifies a family, and the first name identifies a person within that family.

The event loop library provides macros to declare and define the event base easily.

Event base declaration:

ESP_EVENT_DECLARE_BASE(EVENT_BASE) ; <---- MISSING semicolon
Event base definition:

ESP_EVENT_DEFINE_BASE(EVENT_BASE) ; <----- MISSING semicolon

thx

@adokitkat
Copy link
Collaborator

adokitkat commented Feb 12, 2024

I see now. However I don't think that's a mistake, since ESP_EVENT_DECLARE_BASE and ESP_EVENT_DEFINE_BASE are C macros which output statements. And in C after statement there needs to be a semicolon.

#define ESP_EVENT_DECLARE_BASE(id) extern esp_event_base_t const id
#define ESP_EVENT_DEFINE_BASE(id) esp_event_base_t const id = #id

You aren't supposed to copy it from docs like ESP_EVENT_DECLARE_BASE(EVENT_BASE), you need to use it like e.g.:

...
ESP_EVENT_DECLARE_BASE(s_your_base_variable);
...

But I can see how it can be confusing.

@espressif-bot espressif-bot added Status: In Progress Work is in progress Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Opened Issue is new Status: In Progress Work is in progress labels Feb 19, 2024
espressif-bot pushed a commit that referenced this issue Mar 1, 2024
This commit adds semicolons in c-code blocks in esp_event.rst for
improved user experience when directly copying and pasting code.

Closes #13156
espressif-bot pushed a commit that referenced this issue Mar 5, 2024
This commit adds semicolons in c-code blocks in esp_event.rst for
improved user experience when directly copying and pasting code.

Closes #13156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants