Go Down

Topic: error in library file (Read 519 times) previous topic - next topic

shannonn

Nov 13, 2012, 09:39 am Last Edit: Nov 13, 2012, 09:48 am by Coding Badly Reason: 1
An error occurred when i tried to upload the file into arduino atmega2560. Below is one of the library files where the error is highlighted at.
The error says:
Code: [Select]
herkulex.h:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'herkulex'
herkulex.c:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
herkulex.c:166: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
herkulex.c:172: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
herkulex.c:194: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
herkulex.c:285: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token


And the 'class' word in this file is highlighted.

May I know what's wrong with this code? Thanks!

code:

Code: [Select]
#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_ */



Moderator edit: [code] [/code] tags added.

Coding Badly


DrsPacket is defined in your code.

shannonn

Sorry do you mean that DrsPacket should be defined in this library?
It is a typedef struct that i defined in herkulex.c file.

Coding Badly


I'm saying what you have posted is inadequate for the purpose of determining why you are having trouble compiling.

PaulS

Quote
Sorry do you mean that DrsPacket should be defined in this library?
It is a typedef struct that i defined in herkulex.c file.

Why is it defined in the source file when it is referenced in the header file? If it is defined in the header file, it can be referenced in the source, but the opposite is not true.

Go Up