Passing arrays into libraries

Hi all,

I am having problems passing arrays to a library.

I am making a library to deal with my RFID projects, the library has a class RFIDTag.

RFIDTag holds a 100khz tag id which is 14 ints in length int _tagID[14];

The goal is when the constructor is called that I will store the passed ID into the _tagID varible. The class also will handle tag checking as well.

I keep getting an error, that I dont understand I know it has something to do with how I am using the passed varible

/Applications/Arduino.app/Contents/Resources/Java/libraries/RFIDTag/RFIDTag.cpp: In constructor 'RFIDTag::RFIDTag(int*)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/RFIDTag/RFIDTag.cpp:10: error: incompatible types in assignment of 'int*' to 'int [14]'

I am using Arduino 1.0 FYI

I am having problems passing arrays to a library.

We need to see the declaration of the array (missing), the call to the function (missing), the function declaration (missing), the function implementation (missing), and the error (provided).

RFIDTag holds a 100khz tag id which is 14 ints in length int _tagID[14];

Are you sure that that is not 14 bytes?

Yes 14 Bytes, I treat them as int's though

but here is my code that caused the above complie error RFIDTag.cpp

// RFIDTag.cpp
// Ashley Hughes

#include "RFIDTag.h"
#include "Arduino.h"

RFIDTag::RFIDTag(int tag1[])
{
    //store tag infomation locally
    _tag = tag1;
    delay(100);
}

boolean RFIDTag::tagMatches(int testTag[])
{
    return true;
}
// RFIDTag.h
// Ashley Hughes

#ifndef RFIDTag_h
#define RFIDTag_h

#include "Arduino.h"

class RFIDTag
{
public:
    RFIDTag(int tag1[]);
    boolean tagMatches(int testTag[]);
private:
    int _tag[14];
};

#endif

You can’t assign an array like that. You can copy it though:

RFIDTag::RFIDTag(int tag1[])
{
	//store tag infomation locally
	memcpy (_tag, tag1, sizeof (_tag));
	delay(100);
}

Since you appear to be expecting 14 ints why not make it explicit?

RFIDTag::RFIDTag(int tag1[14])
{
	//store tag infomation locally
	memcpy (_tag, tag1, sizeof (_tag));
	delay(100);
}

Thanks Nick that seams to be working at the moment (Compling anyways).

I am going to start adding some logic in to the empty shell.

Out of intrest memcpy is a C method?

Another question I just thought of do I need to do the same thing in my sketch memcpy to use it.

Most of the use of the array will be handled in class it self but just in case I need to.

I’m not sure I understand the question. Use it how?

Out of intrest memcpy is a C method?

Function. Try Googling it. It’s been around for ages.

thanks that helped alot