Espressif NONOS SDK header files
Posted: Mon Apr 01, 2019 1:45 pm
Yesterday I finally got enough fed up with the SDK header files:
- unnecessary use of #define (which is "not recommend" for various reasons)
- #defines to #defines to #defines
- #defines to typedefs and #defines to functions
- the ugly (u)int(8|16|32) types
- the redefinition of (u)int(8|16|32)_t types that are already (correctly) defined in stdint.h
- redefinition of bool and true|false
- lots of other stuff that makes GCC choke
- completely random inclusion of items in each header file, there is little system there, so you usually end up including ALL of them, to be sure
I copied the bits I am using to two files, sdk.h for software stuff, eagle.h for hardware stuff, replaced all the #defines by enum and static inline functions (where necessary) and in the process added values that are not disclosed by Espressif but reverse engineered by some people. Also, of course, used the correct types now (uint*_t) everywhere, and added some "const" qualifiers here and there, where appropriate.
Then I removed the SDK include directory from the header search path.
Works like a charm. Good move, if I may say myself
If there is more interest, we might want to make the maintaince of this a shared effort. At the moment I am not afraid much more will change in the SDK headers files, though.
- unnecessary use of #define (which is "not recommend" for various reasons)
- #defines to #defines to #defines
- #defines to typedefs and #defines to functions
- the ugly (u)int(8|16|32) types
- the redefinition of (u)int(8|16|32)_t types that are already (correctly) defined in stdint.h
- redefinition of bool and true|false
- lots of other stuff that makes GCC choke
- completely random inclusion of items in each header file, there is little system there, so you usually end up including ALL of them, to be sure
I copied the bits I am using to two files, sdk.h for software stuff, eagle.h for hardware stuff, replaced all the #defines by enum and static inline functions (where necessary) and in the process added values that are not disclosed by Espressif but reverse engineered by some people. Also, of course, used the correct types now (uint*_t) everywhere, and added some "const" qualifiers here and there, where appropriate.
Then I removed the SDK include directory from the header search path.
Works like a charm. Good move, if I may say myself
If there is more interest, we might want to make the maintaince of this a shared effort. At the moment I am not afraid much more will change in the SDK headers files, though.