Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By jcmvbkbc
#75743
jj8431 wrote:there's a 'LOCAL' key word in front of a variable definition, What does it mean and how/when to use it?

It's a macro defined in the SDK:
Code: Select all$ grep -rw LOCAL | grep define
ESP8266_NONOS_SDK_V2.0.0_16_08_10/include/c_types.h:#define LOCAL       static
ESP8266_NONOS_SDK_V2.0.0_16_08_10/include/c_types.h.orig:#define LOCAL       static
xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/include/c_types.h:#define LOCAL       static
xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/include/c_types.h.orig:#define LOCAL       static
esp_iot_sdk_v1.5.2/include/c_types.h:#define LOCAL       static
esp_iot_sdk_v1.5.2/include/c_types.h.orig:#define LOCAL       static

There's no reason to use it instead of using 'static' keyword directly.
User avatar
By McChubby007
#75749 Redefining a C++ keyword is not recommended IMHO and it just leads to confusion/readability as is exemplified here.
Static at module (file) scope means it is a global variable only within usable scope of the module/file it is defined within. It is the C way of making variables semi-private but shareable within a set of functions (very loosely like class variables in C++). The variables are hidden from other modules/files, and cannot be accessed via an extern keyword; they also allow the compiler more chance to make optimisations.