未定义的函数引用(uint8_t)

时间:2017-04-11 20:42:01

标签: c++ arduino uint8t

LiquidCrystal.h文件中声明了这样的构造函数:

class LiquidCrystal {    
    public :
    LiquidCrystal(uint8_t rs, 
            uint8_t enable,
            uint8_t d0, 
            uint8_t d1, 
            uint8_t d2, 
            uint8_t d3);
}

LiquidCrystal.cpp:

#include "LiquidCrystal.h"

LiquidCrystal::LiquidCrystal(uint8_t rs,  uint8_t enable,
                 uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
{
  init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0);
}

void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
             uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
             uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
{
  // Some code 
}

我试图像这样打电话给那个人:

#include <LiquidCrystal.h>

int main(void) {

    LiquidCrystal* lcd = new LiquidCrystal(6, 7, 5, 4, 3, 8);
    // Rest of the code
}

它出现以下错误:undefined reference to 'LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'

正确包含头文件,因为如果我喜欢这样,它会正确编译:

#include <LiquidCrystal.h>

int main(void) {

    uint8_t number6 = 6;
    uint8_t number7 = 7;
    uint8_t number5 = 5;
    uint8_t number4 = 4;
    uint8_t number3 = 3;
    uint8_t number8 = 8;

    LiquidCrystal* lcd = new LiquidCrystal(number6, number7, number5, number4, number3, number8);
    // Rest of the code
}

那么,有没有办法避免逐个声明uint8_t变量并直接传递整数(比如将它转换为uint_8)?

EDIT1:头文件可以在这里找到:https://github.com/arduino-libraries/LiquidCrystal/blob/master/src/LiquidCrystal.h

EDIT2: Image

LiquidCrystal库添加如下: (在Eclipse中)右键单击项目 - &gt;项目属性 - &gt; C / C ++ Build - &gt;编译器 - &gt;一般 - &gt;包含路径 - &gt;添加 - &gt; (LiquidCrystal.cpp和LiquidCrystal.h存在的文件夹)

0 个答案:

没有答案