'DDRD' was not declared in this scope

You are attempting to use low level access to registers appropriate for the AVR architecture (Arduino Uno etc.) . The ESP32/ 8266 is completely different.