SML需要C++14支持。

huangapple go评论99阅读模式
英文:

SML requires C++14 support

问题

  1. 我刚开始学习Adruino,并想在其中使用[boost sml库](https://github.com/boost-ext/sml/tree/master)。我下载了sml.hpp文件,并通过库管理器将其添加到了Arduino项目中。但当我尝试运行文件时,我收到了以下错误消息:
  2. error: #error "[Boost::ext].SML需要支持C++14 (Clang-3.4+,GCC-5.1+,MSVC-2015+)"
  3. #error "[Boost::ext].SML需要支持C++14 (Clang-3.4+,GCC-5.1+,MSVC-2015+)"
  4. 我的Arduino配置:
  5. {
  6. "board": "arduino:avr:micro",
  7. "programmer": "avrisp",
  8. "port": "/dev/ttyACM0",
  9. "output": "../build",
  10. "sketch": "test.ino",
  11. "intelliSenseGen": "global"
  12. }
  13. 我使用的是avr-gcc (gcc版本 7.3.0 (GCC),所以应该支持c++14?)。
  14. 我在c_cpp_properties.json文件中将c++版本更改为了14
  15. "configurations": [
  16. {
  17. "name": "Arduino",
  18. "compilerPath": "home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++",
  19. "compilerArgs": [
  20. "-w",
  21. "-std=c++14",
  22. "-fpermissive",
  23. "-fno-exceptions",
  24. "-ffunction-sections",
  25. "-fdata-sections",
  26. "-fno-threadsafe-statics",
  27. "-Wno-error=narrowing"
  28. ],
  29. "intelliSenseMode": "gcc-x64",
  30. "includePath": [
  31. "home/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino",
  32. "home/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/micro",
  33. "/home/Arduino/libraries/src",
  34. "/home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include",
  35. "/home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include-fixed",
  36. "/home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include"
  37. ],
  38. "forcedInclude": [
  39. "/home/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino/Arduino.h"
  40. ],
  41. "cStandard": "c11",
  42. "cppStandard": "c++14",
  43. "defines": [
  44. ...
  45. "__cplusplus=201402L",
  46. ...
  47. ]
  48. }
  49. ]
  50. 错误发生在sml.hpp文件中:
  51. #if (__cplusplus < 201305L && _MSC_VER < 1900)
  52. #error "[Boost::ext].SML需要支持C++14 (Clang-3.4+,GCC-5.1+,MSVC-2015+)"
  53. #else
  54. 任何帮助都将不胜感激。
  55. 最好的祝愿
  56. 编辑:
  57. 我的avr-g++的tasks.json文件:
  58. "version": "2.0.0",
  59. "tasks": [
  60. {
  61. "type": "cppbuild",
  62. "label": "C/C++: avr-g++构建活动文件",
  63. "command": "/home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++",
  64. "args": [
  65. "-fdiagnostics-color=always",
  66. "-g",
  67. "${file}",
  68. "-o",
  69. "${fileDirname}/${fileBasenameNoExtension}",
  70. "-w"
  71. <details>
  72. <summary>英文:</summary>
  73. I am starting out with Adruino and wanted to use the [boost sml library](https://github.com/boost-ext/sml/tree/master) on it. I downloaded the sml.hpp file and added it to arduino project using the library manager. But when i try to run the file I get the following **error message:**

error: #error "[Boost::ext].SML requires C++14 support (Clang-3.4+, GCC-5.1+, MSVC-2015+)"
#error "[Boost::ext].SML requires C++14 support (Clang-3.4+, GCC-5.1+, MSVC-2015+)"

  1. **My Arduino:**

{
"board": "arduino:avr:micro",
"programmer": "avrisp",
"port": "/dev/ttyACM0",
"output": "../build",
"sketch": "test.ino",
"intelliSenseGen": "global"
}

  1. I am using avr-gcc (gcc version 7.3.0 (GCC) so it should support c++14?)
  2. I changed the version of c++ to 14 in the **c_cpp_properties.json**

"configurations": [
{
"name": "Arduino",
"compilerPath": "home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++",
"compilerArgs": [
"-w",
"-std=c++14",
"-fpermissive",
"-fno-exceptions",
"-ffunction-sections",
"-fdata-sections",
"-fno-threadsafe-statics",
"-Wno-error=narrowing"
],
"intelliSenseMode": "gcc-x64",
"includePath": [
"home/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino",
"home/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/micro",
"/home/Arduino/libraries/src",
"/home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include",
"/home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include-fixed",
"/home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include"
],
"forcedInclude": [
"/home/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino/Arduino.h"
],
"cStandard": "c11",
"cppStandard": "c++14",
"defines": [
...
"__cplusplus=201402L",
...

  1. The error gets thrown in the sml.hpp file

#if (__cplusplus < 201305L && _MSC_VER < 1900)
#error "[Boost::ext].SML requires C++14 support (Clang-3.4+, GCC-5.1+, MSVC-2015+)"
#else

  1. Any help is appreciated.
  2. Best regards
  3. **Edit**
  4. My tasks.json for avr-g++ :

"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: avr-g++ build active file",
"command": "/home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-w",
"-std=c++14",
"-fpermissive",
"-fno-exceptions",
"-ffunction-sections",
"-fdata-sections",
"-fno-threadsafe-statics",
"-Wno-error=narrowing"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /home/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++"
}
]
}

  1. </details>
  2. # 答案1
  3. **得分**: 2
  4. {
  5. "board": "arduino:avr:micro",
  6. "programmer": "avrisp",
  7. "port": "/dev/ttyACM0",
  8. "output": "../build",
  9. "sketch": "test.ino",
  10. "intelliSenseGen": "global",
  11. "buildPreferences": [
  12. ["build.extra_flags", "-std=c++14"]
  13. ]
  14. }
  15. <details>
  16. <summary>英文:</summary>
  17. After looking at the option. I found the build preferences:
  18. I added following flag to the arduino.json:
  19. {
  20. &quot;board&quot;: &quot;arduino:avr:micro&quot;,
  21. &quot;programmer&quot;: &quot;avrisp&quot;,
  22. &quot;port&quot;: &quot;/dev/ttyACM0&quot;,
  23. &quot;output&quot;: &quot;../build&quot;,
  24. &quot;sketch&quot;: &quot;test.ino&quot;,
  25. &quot;intelliSenseGen&quot;: &quot;global&quot;,
  26. &quot;buildPreferences&quot;: [
  27. [&quot;build.extra_flags&quot;, &quot;-std=c++14&quot;]
  28. ]
  29. </details>

huangapple
  • 本文由 发表于 2023年7月18日 03:46:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76707665.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定