(function) was not declared in this scope

I'm having trouble as I learn how to move code into multiple files. I'm currently stuck with this error when I compile.

'get_sat_rssi' was not declared in this scope

main file

#include "get_rssi.h"
#include "input.h"
  
void setup() {
  Serial.begin(9600);
}

void loop() {
  get_command_from_pc();
}

get_rssi.h

#ifndef GET_RSSI_H
#define GET_RSSI_H
#include <Arduino.h>

void get_sat_rssi() ;

#endif

input.h

#ifndef INPUT_H
#define INPUT_H
#include <Arduino.h>

void get_command_from_pc() ;

#endif

input.cpp

#include "input.h";

void get_command_from_pc() {
        get_sat_rssi();
}

get_rssi.cpp

#include "get_rssi.h";

void get_sat_rssi() {
  Serial.print("asdf");

}

try adding #include "get_rssi.h" in your input.h

That did it! Thank you.

I don't understand why though. Wasn't it already included on the first line of my main program?

Yes, but it was not included in your input.cpp, which is compiled separately.The main program wouldn't even need this include, because it doesn't call
get_sat_rssi();

1 Like

I see. Thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.