I am trying to build the project which has many .h files and .cpp file
I made folder in Lib for each include
Project
|- lib
|- Lib 1
|- .h
|- .cpp
|- Lib 2
|- .h
|- .cpp
src
|- .ino
I am getting error on this specific Headers -
#include “src/modified/Streaming.h”
#include “src/fuel_gauge/max1720x_weng.h”
I tried to make an src file in Lib and it didn’t work
I tried to put the folders in src didn’t work
Don’t use .ino files! Write valid header (.h) and .cpp files.
Put your header files into “include
” folder as described in the readme inside this folder.
Put your your implementation files (.cpp) into “src
” and / or subfolders of ‘src’ like so:
.
├── include
│ ├── module1.h
│ ├── module2.h
│ └── module3.h
├── src
│ ├── module1
│ │ └── module1.cpp
│ ├── module2
│ │ └── module2.cpp
│ ├── module3
│ │ └── module3.cpp
│ └── main.cpp
└── platformio.ini
include/module1.h
:
#pragma once
void function_from_module1();
include/module2.h
:
#pragma once
void function_from_module2();
include/module3.h
:
#pragma once
void function_from_module3();
src/module1/module1.cpp
:
#include "module1.h"
#include <Arduino.h>
void function_from_module1() {
Serial.println("This is 'function_from_module1()'");
}
src/module2/module2.cpp
:
#include "module2.h"
#include <Arduino.h>
void function_from_module2() {
Serial.println("This is 'function_from_module2()'");
}
src/module3/module3.cpp
:
#include "module3.h"
#include <Arduino.h>
#include "module1.h"
#include "module2.h"
void function_from_module3() {
Serial.println("This is 'function_from_module3' calling 'function_from_module1' and 'function_from_module2'");
function_from_module1();
function_from_module2();
}
src/main.cpp
:
#include <Arduino.h>
#include "module1.h"
#include "module2.h"
#include "module3.h"
void setup() {
Serial.begin(115200);
function_from_module1();
function_from_module2();
function_from_module3();
}
void loop() {}
1 Like