- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 javascript/typescript 开发人员,但对 Arduino/c++ 很陌生
我有一个类(见下面的 h 和 cpp)并且有这个编译器错误:
DotMatrix.cpp:13:1: error: redefinition of 'DotMatrix::DotMatrix(uint8_t, MD_MAX72XX::moduleType_t, uint8_t, uint8_t, uint8_t)'
DotMatrix::DotMatrix(uint8_t maxDevices, MD_MAX72XX::moduleType_t hardwareType, uint8_t clkPin, uint8_t dataPin, uint8_t csPin)
^
In file included from sketch/DotMatrix.cpp:5:0:
DotMatix.h:10:3: error: 'DotMatrix::DotMatrix(uint8_t, MD_MAX72XX::moduleType_t, uint8_t, uint8_t, uint8_t)' previously defined here
DotMatrix(uint8_t maxDevices, MD_MAX72XX::moduleType_t hardwareType, uint8_t clkPin, uint8_t dataPin, uint8_t csPin)
^
exit status 1
我不明白为什么...
#ifndef DotMatrix_h
#define DotMatrix_h
#include <MD_MAX72xx.h>
#include <MD_Parola.h>
class DotMatrix
{
public:
DotMatrix(uint8_t maxDevices, MD_MAX72XX::moduleType_t hardwareType, uint8_t clkPin, uint8_t dataPin, uint8_t csPin)
: _parola(hardwareType, csPin, maxDevices)
{};
void setup();
private:
MD_Parola _parola;
};
#endif
DotMatix.cpp:
#ifndef DotMatrix_cpp
#define DotMatrix_cpp
//#include <stdint.h>
#include "DotMatix.h"
#include "Arduino.h"
#include <MD_Parola.h> // Parola library to scroll and display text on the display (needs MD_MAX72xx library) https://github.com/MajicDesigns/MD_Parola
#include <MD_MAX72xx.h> // Library to control the Maxim MAX7219 chip on the dot matrix module https://github.com/MajicDesigns/MD_MAX72XX
const int FRAME_DELAY = 25;
DotMatrix::DotMatrix(uint8_t maxDevices, MD_MAX72XX::moduleType_t hardwareType, uint8_t clkPin, uint8_t dataPin, uint8_t csPin)
: _parola(hardwareType, csPin, maxDevices)
{
//MD_Parola(MD_MAX72XX::moduleType_t mod, uint8_t csPin, uint8_t numDevices = (uint8_t)'\001')
_parola = MD_Parola(hardwareType, csPin, maxDevices);
}
void DotMatrix::setup()
{
this->_parola.begin();
_parola.displayClear();
_parola.displaySuspend(false);
byte i = 3; //EEPROM.read(0);
_parola.setIntensity(i); // Values from 0 to 15
_parola.setTextEffect(PA_SCROLL_LEFT, PA_SCROLL_LEFT); //in and out effect
_parola.displayScroll("Hallokes ...", PA_LEFT, PA_SCROLL_LEFT, FRAME_DELAY);
}
#endif
作为引用,这是调用该类的 ino 文件的(片段):
#include "DotMatix.h"
// Define the number of 8x8 dot matrix devices and the hardware SPI interface
#define MAX_DEVICES 4
#define HARDWARE_TYPE MD_MAX72XX::DR1CR0RR0_HW
#define CLK_PIN 14 //D5
#define DATA_PIN 13 //D7
#define CS_PIN 2 //D4
DotMatrix dotMatrix(MAX_DEVICES, HARDWARE_TYPE, CLK_PIN, DATA_PIN, CS_PIN);
void setup() {
dotMatrix.setup();
}
void loop() {
}
我正在使用带有 Arduino 扩展的 VS Code IDE。
最佳答案
void func(); // function declaration
void func() { blablabla; } // function definition.
您可能会看到定义和声明之间的简单区别。一个有
{
,另一个没有。 (全局)函数只能在代码库中定义一次,而不是两次。否则你的编译器将不知道选择哪个函数——第一个?第二个?
// in DotMatix.h:
DotMatrix(blablaa)
{}; // yes this is definition
并且还做了:
// in DotMatrix.cpp
DotMatrix::DotMatrix(ublabla, who cares)
{ // also definition
编译器看到同一函数的两个定义并退出并出现错误。
关于c++ - 尽管使用了包含防护,但错误 : redefinition of class,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63325411/
我的印象是 header guards 解决了重新定义的问题。我收到链接器错误,指出 .obj 文件中存在重新定义。这是我包含的 header ,问题在于所有全局声明的重新定义。 #ifndef DI
我正在 Microsoft Azure 中运行企业级应用程序。我想知道 Microsoft Azure 中 DDOS 投影的建议是什么。该文档明确指出该平台受到 DDOS 保护,但没有提供更多详细信息
我正在用 laravel sanctum 进行测试,但这里有一些问题.. 我正在创建管理员守卫。 当我将中间件更改为 auth:sanctum_admin .. 它应该只能由管理员访问,但在这里我可以
我有一个带有延迟加载模块的 Angular 4.3.6 应用程序。这是部分根路由器: const routes: Routes = [ { path: '', redirectTo: 'fleet
我有 Vaadin UI 的后端。我想保护后端数据库免受XSS攻击。对于 Vaadin UI 的 XSS 防护,您有何建议? 最佳答案 Vaadin 内置了 XSS 保护。所有组件都正确转义/编码 h
我正在尝试提高我的应用程序的安全性。每当我从用户(无论是通过 POST 还是 GET)接收到应该是整数的数据时,我都会适本地对其进行验证。但通常数据是 VARCHAR,有时可以包含 HTML。 在这种
我有一个具有此功能的服务,它会在 token 有效或无效时返回 true 或 false loggedIn() { return this.http.get('http://localhost:300
我们的应用程序中有几条路线,用户不应通过直接在浏览器的地址栏中输入网址来导航这些路线。 相反,当我们使用 router.navigate() 通过我们的应用程序逻辑以编程方式导航时,我们只想让它们可访
我通常在 .NET 中编写我的 SQL sql.Append("SELECT id, code, email FROM mytable WHERE variable = @variable "); 然
我需要同时将多行(1000 行)插入到 SQL Server 数据库中。我认为最好的方法是使用 SqlBulkCopy 但我不确定如何参数化插入查询以防止 SQL 注入(inject)。 你能帮我一下
Laravel 5.7 PHP 7.2.10 目前我可以使用 Web 和 api 防护中的任何一个,是否有任何方法可以同时允许两者,以便 Web 应用程序和 api 能够协同工作。 类似的东西 ret
Guard 总是因为这个问题而困扰我: .../gems/bundler-1.6.2/lib/bundler/runtime.rb:34:in `block in setup': You have a
我正在尝试通过 gmail api 从 Google 获取邮件 在收到 token 后对 Google_Client 进行身份验证时出现此错误 fatal error :未捕获异常“Google_Au
我是一名优秀的程序员,十分优秀!