WIFI was not declared in this scope

You haven’t done a #include <WiFi.h> in the file where you are using the WiFi class.

You either solve the problem through clean C++ code or through global build flags. If you want to have a macro that needs to re-usable, do not put it in a .cpp file as you have done, but put it in a header file. E.g.,

my_settings.h

#ifndef _MY_SETTINGS_H
#define _MY_SETTINGS_H

#define WIFILED 32

#endif /* _MY_SETTINGS_H */

Then include my_settings.h in each .c file where you use that macro.

The other way would be through build_flags = -D WIFILED=32 in the platformio.ini to define the macro in every invocation of the compiler. See docs. Solving it in the language as compared to in the build system should be your preferred way though.

You are also incorrectly mixing C and C++ code here. First, in this .c file, you are calling Arduino C++ APIs – that should be an immediate build error due to name mangling. I’m assuming you made a typo here and it’s actually myhelperfunction.c.

In C++, this can be constexpr. Marking it a constant expression also lets you do neat stuff like defining global constant variables with members initialized by calls to this function.

In C++, no there’s need to typedef it.