MarlinFirmware/Marlin

Marlin 3D Printer Firmware
GitHub GitHub contributors GitHub Release Date Build Status

Additional documentation can be found at the Marlin Home Page. Please test this firmware and let us know if it misbehaves in any way. Volunteers are standing by!

Marlin 2.0
Marlin 2.0 takes this popular RepRap firmware to the next level by adding support for much faster 32-bit and ARM-based boards while improving support for 8-bit AVR boards. Read about Marlin’s decision to use a “Hardware Abstraction Layer” below.

Download earlier versions of Marlin on the Releases page.

Building Marlin 2.0
To build Marlin 2.0 you’ll need Arduino IDE 1.8.8 or newer or PlatformIO. Detailed build and install instructions are posted at:

Installing Marlin (Arduino)
Installing Marlin (VSCode).
Supported Platforms
Platform MCU Example Boards
Arduino AVR ATmega RAMPS, Melzi, RAMBo
Teensy++ 2.0 AT90USB1286 Printrboard
Arduino Due SAM3X8E RAMPS-FD, RADDS, RAMPS4DUE
LPC1768 ARM® Cortex-M3 MKS SBASE, Re-ARM, Selena Compact
LPC1769 ARM® Cortex-M3 Smoothieboard, Azteeg X5 mini, TH3D EZBoard
STM32F103 ARM® Cortex-M3 Malyan M200, GTM32 Pro, MKS Robin, BTT SKR Mini
STM32F401 ARM® Cortex-M4 ARMED, Rumba32, SKR Pro, Lerdge, FYSETC S6
STM32F7x6 ARM® Cortex-M7 The Borg, RemRam V1
SAMD51P20A ARM® Cortex-M4 Adafruit Grand Central M4
Teensy 3.5 ARM® Cortex-M4
Teensy 3.6 ARM® Cortex-M4
Submitting Changes
Submit Bug Fixes as Pull Requests to the (bugfix-2.0.x) branch.
Follow the Coding Standards to gain points with the maintainers.
Please submit your questions and concerns to the Issue Queue.
Marlin Support
For best results getting help with configuration and troubleshooting, please use the following resources:

Marlin Documentation - Official Marlin documentation
Marlin Discord - Discuss issues with Marlin users and developers
Facebook Group “Marlin Firmware”
RepRap.org Marlin Forum
Tom’s 3D Forums
Facebook Group “Marlin Firmware for 3D Printers”
Marlin Configuration on YouTube
Credits
The current Marlin dev team consists of:

Scott Lahteine [@thinkyhead] - USA Donate
Roxanne Neufeld [@Roxy-3D] - USA
Chris Pepper [@p3p] - UK
Bob Kuhn [@Bob-the-Kuhn] - USA
Erik van der Zalm [@ErikZalm] - Netherlands Flattr Erik
License
Marlin is published under the GPL license because we believe in open development. The GPL comes with both rights and obligations. Whether you use Marlin firmware as the driver for your open or closed-source product, you must keep Marlin open, and you must provide your compatible Marlin source code to end users upon request. The most straightforward way to comply with the Marlin license is to make a fork of Marlin on Github, perform your modifications, and direct users to your modified fork.

While we can’t prevent the use of this code in products (3D printers, CNC, etc.) that are closed source or crippled by a patent, we would prefer that you choose another firmware or, better yet, make your own.

### 关于“常量表达式中不允许函数调用”的错误分析 在 C/C++ 编程中,“常量表达式中不允许函数调用”这一错误通常发生在尝试将某些运行时计算的结果用于需要编译时常量的地方。这种情况下,编译器无法接受动态计算的内容作为初始化值。 #### 错误原因解析 当使用 `constexpr` 或者其他形式的编译期常量声明时,如果涉及到了非纯编译期可求解的操作(比如函数调用),就会触发此类错误。例如,在 C++ 中,`const` 和 `constexpr` 的语义不同,`const` 表示的是不可修改的变量,但它并不一定是在编译期间就能确定其值;而 `constexpr` 则强制要求所表示的对象或者返回值必须能在编译阶段被完全评估出来[^1]。 对于特定情况下的 `'this'不能用于常量表达式` 报错来说,这主要是因为 `this` 是一个指向当前实例对象的指针,它本身不是编译时期可知的信息,因此不能参与那些要求严格意义上的编译时间决定逻辑之中[^3]。 #### 解决方法探讨 为了规避这个问题,可以采取如下几种策略: 1. **确保所有参与运算的因素均为真正的编译期常数** 如果可能的话,应尽量重构代码使得所有的输入都成为真正意义上面向编译时期的已知数值。这意味着要避免任何依赖运行环境状态的数据结构访问或者是间接寻址之类的操作。 2. **利用模板元编程技术实现复杂计算** 对于一些较为复杂的算术处理需求,可以通过引入标准库提供的工具类 `<type_traits>` 来完成必要的类型推导工作,甚至自定义特化版本来满足具体应用场景的需求[^2]。 下面提供一段示范性的修正版代码片段展示如何正确运用这些概念: ```cpp #include <iostream> #include <cmath> // 定义一个简单的 constexpr 函数来进行平方根计算 constexpr double sqrt_constexpr(double value){ return (value >=0)?std::sqrt(value):throw std::domain_error("negative input"); } struct ExampleStruct { private: static const int STATIC_CONST_VAR; public: void exampleMethod() const{ // 此处故意制造了一个非法场景演示问题所在 // auto invalidConstExpr = this->STATIC_CONST_VAR * 2; // Error: 'this' cannot be used in constant expressions // 修改后的合法方式 constexpr int validConstValue = ExampleStruct::STATIC_CONST_VAR * 2; std::cout << "Valid Const Value:" << validConstValue << "\n"; // 展示另一个关于constexpr使用的例子 try{ constexpr double result = sqrt_constexpr(ExampleStruct::STATIC_CONST_VAR); std::cout << "Square root of static var as constexpr:"<<result<<"\n"; } catch(const std::exception& e){ std::cerr<<e.what()<<'\n'; } } }; // 初始化静态成员变量 const int ExampleStruct::STATIC_CONST_VAR = 8; int main(){ ExampleStruct es; es.exampleMethod(); } ``` 以上代码展示了几个要点:一是通过显式的 `constexpr` 声明让编译器知道哪些地方是可以安全展开成即时替换的形式;二是针对可能出现异常的情况做了妥善管理以防程序崩溃^。 ### 总结 综上所述,面对 “常量表达式中不允许函数调用” 这样的编译错误时,关键是理解清楚到底是什么因素阻止了目标表达式变成纯粹由编译器掌控的东西,并据此调整设计思路使之符合语言规范的要求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值