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

[TW#17868] C macro comparison against typedef constant ... #1526

Closed
nkolban opened this issue Jan 20, 2018 · 2 comments
Closed

[TW#17868] C macro comparison against typedef constant ... #1526

nkolban opened this issue Jan 20, 2018 · 2 comments

Comments

@nkolban
Copy link
Contributor

nkolban commented Jan 20, 2018

I'm having some issues compiling with esp_log.h and am stumped by what I am finding.

If we look here:

https://github.com/espressif/esp-idf/blob/master/components/log/include/esp_log.h#L164

We find the following definition:

#if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO)

I interpret this to be executing the following logic if the value of the macro LOG_LOCAL_LEVEL is greater or equal to the value of the macro ESP_LOG_INFO. That sounds fair. However, the macro ESP_LOG_INFO is not defined. Instead, we have a typedef at:

https://github.com/espressif/esp-idf/blob/master/components/log/include/esp_log.h#L35

That looks as follows:

typedef enum {
    ESP_LOG_NONE,       /*!< No log output */
    ESP_LOG_ERROR,      /*!< Critical errors, software module can not recover on its own */
    ESP_LOG_WARN,       /*!< Error conditions from which recovery measures have been taken */
    ESP_LOG_INFO,       /*!< Information messages which describe normal flow of events */
    ESP_LOG_DEBUG,      /*!< Extra information which is not necessary for normal use (values, pointers, sizes, etc). */
    ESP_LOG_VERBOSE     /*!< Bigger chunks of debugging information, or frequent messages which can potentially flood the output. */
} esp_log_level_t;

It is my naive belief that the C pre-processor doesn't know anything about typedefs or variables. How could this possible work?

@igrr
Copy link
Member

igrr commented Jan 20, 2018

Thanks for raising this @nkolban, we have a fix for this issue in the merge queue at the moment. Should appear on GitHub soon.

@FayeY FayeY changed the title C macro comparison against typedef constant ... [TW#17868] C macro comparison against typedef constant ... Jan 24, 2018
@igrr
Copy link
Member

igrr commented Jan 28, 2018

My bad, the fix in the merge queue was for a different issue. New fix for this issue coming shortly.

@igrr igrr closed this as completed in 527be44 Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants