WIFI was not declared in this scope

I’m just switching over from the Arduino ide to PlatformIO.
So far so good, single ino files are not that hard to switch over.
However project with multiply ino’s is much harder to get compiled.

I have made this simple sample. The compiler keeps complaining WIFI was not declared in this scope
What am i doing wrong, what’s the correct place for #define WIFILED 32 so that you can use it globally.


#include <Arduino.h>
#include “myhelperfunctions.h”

#define WIFILED 32

void setup() {
person me = {
.first_name = “Dummy”,
.last_name = “Man”,
.age = add(2018, -1800),
Serial.print(me.first_name + " " + me.last_name + " is “);
Serial.println(” years old.");

void loop() {


typedef struct {
String first_name;
String last_name;
long age;
} person;

long add(int a, int b);

void blinkledshort(byte blinks);


#include <Arduino.h>

long add(int a, int b) {
return a + b;

void blinkledshort(byte blinks) {
for (int i = 1; i <= blinks; i++) {
digitalWrite(WIFILED, HIGH);
digitalWrite(WIFILED, LOW);

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.,


#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.