title: cpp/PlatformIO class dependencies
body: <p>I'm increasing an arduino project by adding an external Analog to Digital Converter.</p>
  <p>For that I'm using the Mcp3208 library.
  My code is organise with one class by sensor and I need to access to a Mcp3208 instance (adc) from different classes.</p>
  <p>So I created a common lib include in the different classes but this is not working. I'm searching from few hours on the net but I have not found an article to help me.</p>
  <p>Can you explain me the right way to do that?
  I'm coding with Atom and the platformIO plugin.</p>
  <p>I've a FSM class who instantiate sensors (.h) :</p>
  <pre><code>#ifndef FSM_H_
  #define FSM_H_
  
  #include &quot;EnvironmentalSensor.h
  #include &quot;PowerSensor.h&quot;
  
  class FSM {
      FSM();
      virtual ~FSM();
  
  public:
      do_stuff();
  
  private:
      EnvironmentalSensor envSensor1(params);
      PowerSensor envSensor1(params);
  }
  #endif
  </code></pre>
  <p>The common class instantiate the Mcp3208 as adc (.h):</p>
  <pre><code>#ifndef COMMONS_H_
  #define COMMONS_H_
  
  #include &quot;Mcp3208.h&quot;
  
  #define SPI_CS      29         // SPI slave select
  #define ADC_VREF    5000     // 5V Vref
  #define ADC_CLK     1600000  // SPI clock 1.6MHz
  
  #define ADC_2_5 MCP3208::SINGLE_6
  
  #endif /*COMMONS_H_ */
  </code></pre>
  <p>The common class (.cpp):</p>
  <pre><code>#include &quot;Arduino.h&quot;
  #include &quot;commons.h&quot;
  
  extern MCP3208 adc(ADC_VREF, SPI_CS);
  
  void init_adc(){
  
      pinMode(SPI_CS, OUTPUT);        // set spi cs as an output pin
  }
  </code></pre>
  <p>Here is an example for the Environmental class (.cpp), PowerSensor is equal :</p>
  <pre><code>#include &quot;Arduino.h&quot;
  #include &quot;EnvironmentalSensor.h&quot;
  #include &quot;commons.h&quot;
  
  MCP3208 adc;
  
  void EnvironmentalSensor::read(){
      adc.read(SINGLE_0);
  }
  </code></pre>
  <p>Here is an example for the Environmental class (.h), PowerSensor is equal :</p>
  <pre><code>#ifndef EnvironmentalSensor_H_
  #define EnvironmentalSensor_H_
  
  #include &quot;commons.h&quot;
  
  class EnvironmentalSensor{
  
  public :
      read();
  }
  
  #endif
  </code></pre>
  <p>edit :</p>
  <p>The problem is : in the EnvironmentalSensor.cpp the mcp3208 adc give me an error.</p>
  <p>The error window provide me some help :</p>
  <blockquote>
  <p>error:lib/EnvironmentalSensor/src/EnvironmentalSensor.cpp:49:10: error: nomatching function for call to 'MCP3208::MCP3208()'
  MCP3208 adc;</p>
  <p>^</p>
  <p>lib/Power/src/Power.cpp:38:9: note: candidates are: In file included from lib/commons/commons.h:4:0, from lib/Power/src/Power.h:33,</p>
  <p>from lib/Power/src/Power.cpp:34:
  .piolibdeps/Mcp3208_ID1533/src/Mcp3208.h:74:3: note:
  MCP3208::MCP3208(uint16_t, uint8_t) MCP3208(uint16_t vref, uint8_t csPin);</p>
  <p>^</p>
  <p>.piolibdeps/Mcp3208_ID1533/src/Mcp3208.h:74:3: note: candidate expects 2 arguments, 0 provided
  .piolibdeps/Mcp3208_ID1533/src/Mcp3208.h:65:3: note:
  MCP3208::MCP3208(uint16_t, uint8_t, SPIClass*) MCP3208(uint16_t vref, uint8_t csPin, SPIClass *spi);</p>
  <p>^</p>
  <p>.piolibdeps/Mcp3208_ID1533/src/Mcp3208.h:65:3: note:   candidate expects 3 arguments, 0 provided
  .piolibdeps/Mcp3208_ID1533/src/Mcp3208.h:16:7: note: constexpr
  MCP3208::MCP3208(const MCP3208&amp;)
  class MCP3208 {</p>
  <p>^</p>
  <p>.piolibdeps/Mcp3208_ID1533/src/Mcp3208.h:16:7: note:   candidate expects 1 argument, 0 provided
  .piolibdeps/Mcp3208_ID1533/src/Mcp3208.h:16:7: note: constexpr  MCP3208::MCP3208(MCP3208&amp;&amp;)
  .piolibdeps/Mcp3208_ID1533/src/Mcp3208.h:16:7: note:   candidate expects 1 argument, 0 provided</p>
  </blockquote>
  <p>But for me, I have already declare the adc in the commons.cpp</p>
  <p>Thank you,
  gilou</p>