简体   繁体   English

错误:在':'标记前应有'=',',',';','asm'或'__attribute__'

[英]error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token

An error occurred when i uploaded this code to Arduino Atmega2560. 当我将此代码上传到Arduino Atmega2560时发生错误。 This is a libary file which i have created for the .c files in my program. 这是我为程序中的.c文件创建的库文件。

The error is: 错误是:
herkulex.c:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token

The word 'class' is highlighted when the error appears, which is in the file (code shown below) 错误出现时,“ class”一词突出显示,该错误在文件中(如下所示)

#ifndef herkulex_lib
#define herkulex_lib

#include <Arduino.h>
#include <Wire.h> 
#include<inttypes.h> 

class herkulex
{
  public: 
    herkulex();
    void hklx_Init(unsigned long ulBaudRate);
    void hklx_SendPacket(DrsPacket stPacket);
    unsigned char hklx_ucReceivePacket(DrsPacket *pstPacket);
    void hklx_RemoveInvalidData(void);

//no private  
};

#endif /* HERKULEX_H_ */

May I know what's wrong with this code? 我可以知道这段代码有什么问题吗? Thanks! 谢谢!

You are compiling a C file which contains C++. 您正在编译一个包含C ++的C文件。 The C compiler is rejecting C++ syntax. C编译器拒绝C ++语法。

Compile it as a C++ program instead. 而是将其编译为C ++程序。

是不是有一个space在这里失去了:?

#include<inttypes.h> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:在 &#39;:&#39; 标记之前应有 &#39;=&#39;、&#39;、&#39;、&#39;;&#39;、&#39;asm&#39; 或 &#39;__attribute__&#39; - error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token C ++:静态库中的函数返回字符串给出错误:在&#39;:&#39;标记之前应有预期的&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - C++ : Function return String in Static Library give Error : expected '=', ',', ';', 'asm' or '__attribute__' before ':' token 头文件错误:之前应为&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - Header File error: expected '=', ',', ';', 'asm' or '__attribute__' before 预期在“ int”之前出现外部“ C”错误“ =”,“,”,“;”,“ asm”或“ __attribute__” - Extern “C” error expected '=', ',', ';', 'asm' or '__attribute__' before 'int' c ++错误:在&#39;秘密&#39;之前预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - c++ error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘secret’ 在CRenderContext之前预期的asm或__attribute__ - expected asm or __attribute__ before CRenderContext 当我使用:: va_list时,应在&#39;{&#39;标记前加上&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39;。 - expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token when I have using ::va_list; lib \\ app_error.c | 49 |错误:在“无效” Nortic Semi示例之前,预期为“ =”,“,”,“;”,“ asm”或“ __attribute__” - lib\app_error.c|49|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void' Nortic Semi example Tryinig在纯c语言中对arduino进行编程,得到以下错误:在“打印” |之前应为“ =”,“,”,“;”,“ asm”或“ __attribute__” - Tryinig to program arduino in pure c, get the following error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Print'| C ++错误:在“ I2Cdev”(类名)之前应为“ =”,“,”,“;”,“ asm”或“ __attribute__” - C++ error: expected '=', ',', ';', 'asm' or '__attribute__' before 'I2Cdev' (classname)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM