Function which takes and returns an array

I have this code which compile and am converting it to a usable library. However whenever I try to copy it over I am getting errors either to do with pointers or with my classes.

Putting it simply. I would like the function “SpeedRunRoute” found in the library “Solve grid”, to accept the arrays Horizontal and Vertical walls, then output the array “MouseDirectionList”. I tried using pointers but those may be incorrect.

Thanks

Main Test function

/* SolveGrid
 R Matthew 20100123
 
 Solves the Maze
 
 Inputs: 
 byte HorizontalWalls[16][17] 0= No wall, 1= Wall.
 byte VerticalWalls[17][16]   0= No wall, 1= Wall.
 
 Output:
 int MouseDirectionList[512] 0=Forward, 1=Right, 2=Left, 9=End of Instructions
 */

// JAPAN00 Maze For testing purposes only ------------------------------------------
int HorizontalWalls[16][17]= { 
  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
  1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,
  1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
  1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,
  1,0,0,0,1,0,1,0,1,0,1,1,0,1,0,0,1,
  1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,0,1,
  1,0,0,0,1,0,0,1,1,0,1,0,0,1,0,0,1,
  1,0,0,0,1,1,1,0,0,0,1,0,0,1,0,0,1,
  1,0,0,0,0,0,1,1,0,1,1,0,0,1,0,0,1,
  1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,1,
  1,0,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,
  1,0,0,1,1,0,1,0,1,1,1,0,1,0,0,0,1,
  1,0,0,1,0,0,1,0,1,0,1,1,0,0,0,1,1,
  1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,1,
  1,0,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,
  1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1};

int VerticalWalls[17][16]= { 
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
  1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,
  1,0,1,1,0,1,1,0,1,1,1,1,1,1,1,0,
  1,0,1,0,1,0,1,1,1,1,0,0,1,1,0,1,
  1,0,1,1,0,1,0,0,0,0,0,1,0,0,1,0,
  1,0,1,0,0,0,1,0,0,0,1,0,1,1,0,1,
  1,0,1,1,0,0,1,1,1,1,0,1,1,0,1,0,
  0,1,0,1,1,1,0,0,0,0,1,1,0,1,0,1,
  0,1,0,0,1,0,0,1,1,0,0,1,1,1,0,1,
  1,0,1,0,0,1,0,1,0,1,1,0,0,1,0,1,
  0,1,0,1,1,0,1,0,0,0,0,0,1,0,1,0,
  1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,
  0,1,0,0,1,0,1,0,1,1,0,0,1,0,1,1,
  1,0,0,1,1,1,0,1,0,0,1,1,1,1,0,0,
  0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
// END OF TESTING SECTION ------------------------------------------

#include <SolveGrid.h>

SolveGrid solvegrid

// Print Nodes
void setup(){ 
  Serial.begin(9600); 

  int SpeedRoute[512]=solvegrid.SpeedRunRoute(HorizontalWalls[16][17], VerticalWalls[17][16]);


} 


void loop(){
}

SolveGrid.h

/*SolveGrid.h - Header for the Micromouse Grid Code
RMatthew
20100123
*/

#ifndef SolveGrid_h
#define SolveGrid_h
#include "WProgram.h" //Standard librarys


class SolveGrid //Declare a Grid Solver class
{
public:
int SpeedRunRoute(int (HorizontalWalls)[16][17],int (VerticalWalls)[17][16]);

private:
};
#endif

…and Solve Grid.cpp part 1

/* SolveGrid
 R Matthew 20100123
 
 Solves the Maze
 
 Inputs: 
 byte HorizontalWalls[16][17] 0= No wall, 1= Wall.
 byte VerticalWalls[17][16]   0= No wall, 1= Wall.
 
 Output:
 int MouseDirectionList[512] 0=Forward, 1=Right, 2=Left, 9=End of Instructions
 */


#include "WProgram.h" //Include standard library
#include "SolveGrid.h" //Include relevent header file


//--------------------------------------------------------------------------------------
int SolveGrid::SpeedRunRoute(int (HorizontalWalls)[16][17],int (VerticalWalls)[17][16]){

  //-----------------------------------------------------------------------------  
  //Initialising Vairables
  //Entry Coordinates
  const int EntryCoordinatesX =0;
  const int EntryCoordinatesY =0;

  ////Weightings
  //const int WeightDiagonal=5;
  //const int WeightStraight=4;

  //Distance Node Graph
  int Nodes[16][16]={
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
    250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250  };

  // Print Nodes
  //Serial.begin(9600); 

  //  Serial.println("");
  //  Serial.println("Nodes"); 
  //  for (int Rows=0; Rows<=15; Rows++){
  //    for (int Columns=0; Columns<=15; Columns++){  
  //      Serial.print(Nodes[Rows][Columns]);
  //      Serial.print("\t");
  //    }
  //    Serial.println("");
  //  }
  //  Serial.println("");




  //Change Variables (to see if the route is being updated)
  int ChangesOld=0;
  int ChangesNew=1;
  int LastLocationX=EntryCoordinatesX;
  int LastLocationY=EntryCoordinatesY;

  //Cardinal Points
  int NodeNorth=0;
  int NodeEast=0;
  int NodeSouth=0;
  int NodeWest=0;


  //Weightings

  int WeightStraight=1;


  //-----------------------------------------------------------------------------  
  // Start Weighting Grid
  Nodes[EntryCoordinatesX][EntryCoordinatesY]=0;

  for (int counter=1; counter<255; counter++){
    ChangesOld=ChangesNew;
    for (int NodeRows=0; NodeRows<=15; NodeRows++){
      for (int NodeColumns=0; NodeColumns<=15; NodeColumns++){  
        LastLocationX=NodeRows;
        LastLocationY=NodeColumns;

        //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
        // 90 Degree Values
        if (NodeColumns==15){
          NodeNorth=750;
        }
        else{
          NodeNorth=Nodes[LastLocationX][LastLocationY+1];
        }

        if (NodeRows==15){
          NodeEast=750;
        }
        else{
          NodeEast=Nodes[LastLocationX+1][LastLocationY];
        }

        if (NodeColumns==0){
          NodeSouth=750;
        }
        else{
          NodeSouth=Nodes[LastLocationX][LastLocationY-1];
        }

        if (NodeRows==0){
          NodeWest=750;
        }
        else{
          NodeWest=Nodes[LastLocationX-1][LastLocationY];
        }

        // Weightings  
        if ((NodeNorth<=(Nodes[NodeRows][NodeColumns]-WeightStraight)
          &&(HorizontalWalls[NodeRows][NodeColumns+1]==0))){
          Nodes[NodeRows][NodeColumns]=NodeNorth+WeightStraight;
          ChangesNew=ChangesNew+1;
        }  

        if ((NodeEast<=(Nodes[NodeRows][NodeColumns]-WeightStraight)
          &&(VerticalWalls[NodeRows+1][NodeColumns]==0))){
          Nodes[NodeRows][NodeColumns]=NodeEast+WeightStraight;
          ChangesNew=ChangesNew+1;
        }  

        if ((NodeSouth<=(Nodes[NodeRows][NodeColumns]-WeightStraight)
          &&(HorizontalWalls[NodeRows][NodeColumns]==0))){
          Nodes[NodeRows][NodeColumns]=NodeSouth+WeightStraight;
          ChangesNew=ChangesNew+1;
        }  

        if ((NodeWest<=(Nodes[NodeRows][NodeColumns]-WeightStraight)
          &&(VerticalWalls[NodeRows][NodeColumns]==0))){
          Nodes[NodeRows][NodeColumns]=NodeWest+WeightStraight;
          ChangesNew=ChangesNew+1;
        }   
      }
    }
  }  



  //-----------------------------------------------------------------------------  
  // Print Solved Maze
  //  Serial.println("");
  //  Serial.println("Nodes"); 
  //  for (int Rows=0; Rows<=15; Rows++){
  //    for (int Columns=0; Columns<=15; Columns++){  
  //      Serial.print(Nodes[Rows][Columns]);
  //      Serial.print("\t");
  //    }
  //    Serial.println("");
  //  }
  //  Serial.println("");


  //-----------------------------------------------------------------------------  
  // Get Directions

  //Plot Route Vectors
  int RouteX[256]={
    0                  };
  int RouteY[256]={
    0                  };

  //Find Min Destination  
  RouteX[0]=7;
  RouteY[0]=7;
  int MinNodes=Nodes[7][7];
  if (Nodes[7][8]<MinNodes){
    RouteX[0]=7;
    RouteY[0]=8;
    MinNodes=Nodes[7][8];
  };
  if (Nodes[8][7]<MinNodes){
    RouteX[0]=8;
    RouteY[0]=7;
    MinNodes=Nodes[8][7];
  };
  if (Nodes[8][8]<MinNodes){
    RouteX[0]=8;
    RouteY[0]=8;
    MinNodes=Nodes[8][8];
  };

  //  Serial.print(MinNodes);
  //  Serial.println("");
  //  Serial.print(RouteX[0]);
  //  Serial.print("\t");
  //  Serial.print(RouteY[0]);
  //  Serial.print("\t"); 
  //  Serial.println("");

  //-----------------------------------
  //Find Route

  int CellCounter=0;
  while ((RouteX[CellCounter]!=EntryCoordinatesX) || (RouteY[CellCounter]!=EntryCoordinatesY)){ //Could be || according to MATLab?
    //  do{
    //Find Neighbouring Cells
    if (RouteY[CellCounter]==15){
      NodeNorth=750;
    }
    else{
      NodeNorth=Nodes[RouteX[CellCounter]][RouteY[CellCounter]+1];
    }
    if (RouteX[CellCounter]==15){
      NodeEast=750;
    }
    else{
      NodeEast=Nodes[RouteX[CellCounter]+1][RouteY[CellCounter]];
    }
    if (RouteY[CellCounter]==0){
      NodeSouth=750;
    }
    else{
      NodeSouth=Nodes[RouteX[CellCounter]][RouteY[CellCounter]-1];
    }
    if (RouteX[CellCounter]==0){
      NodeWest=750;
    }
    else{
      NodeWest=Nodes[RouteX[CellCounter]-1][RouteY[CellCounter]];
    }

    //Find LowestCell
    int LowestCell=500;
    if (NodeNorth<LowestCell && HorizontalWalls[RouteX[CellCounter]][RouteY[CellCounter]+1]==0){
      LowestCell=NodeNorth;
    }
    if (NodeEast<LowestCell && VerticalWalls[RouteX[CellCounter]+1][RouteY[CellCounter]]==0){
      LowestCell=NodeEast;
    }
    if (NodeSouth<LowestCell && HorizontalWalls[RouteX[CellCounter]][RouteY[CellCounter]]==0){
      LowestCell=NodeSouth;
    }
    if (NodeWest<LowestCell && VerticalWalls[RouteX[CellCounter]][RouteY[CellCounter]]==0){
      LowestCell=NodeWest;
    }

    //Find Path

    if (NodeNorth==LowestCell && HorizontalWalls[RouteX[CellCounter]][RouteY[CellCounter]+1]==0){
      RouteX[CellCounter+1]=RouteX[CellCounter];
      RouteY[CellCounter+1]=RouteY[CellCounter]+1;
    }
    else
      if (NodeEast==LowestCell && VerticalWalls[RouteX[CellCounter]+1][RouteY[CellCounter]]==0){
        RouteX[CellCounter+1]=RouteX[CellCounter]+1;
        RouteY[CellCounter+1]= RouteY[CellCounter];
      }
      else
        if (NodeSouth==LowestCell && HorizontalWalls[RouteX[CellCounter]][RouteY[CellCounter]]==0){
          RouteX[CellCounter+1]=RouteX[CellCounter];
          RouteY[CellCounter+1]=RouteY[CellCounter]-1;
        }
        else
          if (NodeWest==LowestCell && VerticalWalls[RouteX[CellCounter]][RouteY[CellCounter]]==0){
            RouteX[CellCounter+1]=RouteX[CellCounter]-1;
            RouteY[CellCounter+1]=RouteY[CellCounter];
          }
    //Increase Counter Value
    CellCounter+=1;
    // }while (CellCounter <=1);
  }

  //Find Length of Route
  int RouteLength=-1;
  do {  
    RouteLength+=1;
    //    Serial.print(RouteX[RouteLength]);
    //    Serial.print("\t");
    //    Serial.print(RouteY[RouteLength]);
    //    Serial.println("");
  } 
  while ((RouteX[RouteLength]) != 0 || (RouteY[RouteLength]) != 0);
  //  Serial.print(RouteLength);  
  //  Serial.println("");

  //Change route from End->Start to Start->End
  int PathCoordinatesX[256]={
    0      };
  int PathCoordinatesY[256]={
    0      };

  for (int RouteCounter=0; RouteCounter <= RouteLength; RouteCounter++){

    PathCoordinatesX[RouteCounter]=RouteX[RouteLength-RouteCounter];
    PathCoordinatesY[RouteCounter]=RouteY[RouteLength-RouteCounter];
    //    Serial.print(PathCoordinatesX[RouteCounter]);
    //    Serial.print("\t");
    //    Serial.print(PathCoordinatesY[RouteCounter]);
    //    Serial.println("");
  }

… SolveGrid.cpp part 2

  // This is the output section of the algorithm. 
  // Mouse directions: NESW:0123
  // Direction list:   FRL:012

  int MouseDirection =0;
  int MouseDirectionList[512]={
    0    };
  int MouseDirectionListCounter=0;
  int CurrentXCell=PathCoordinatesX[0];
  int CurrentYCell=PathCoordinatesY[0];
  int NextXCell=PathCoordinatesX[0];
  int NextYCell=PathCoordinatesY[0];


  for (int RouteCounter=0; RouteCounter <= RouteLength-1; RouteCounter++){
    int CurrentXCell=PathCoordinatesX[RouteCounter];
    int CurrentYCell=PathCoordinatesY[RouteCounter];
    int NextXCell=PathCoordinatesX[RouteCounter+1];
    int NextYCell=PathCoordinatesY[RouteCounter+1];

    //    Serial.println("");
    //    Serial.print(CurrentXCell);
    //    Serial.print("\t");
    //    Serial.print(CurrentYCell);
    //    Serial.print("\t");
    //    Serial.println("");

    //NORTH
    if ((NextXCell==CurrentXCell) && (NextYCell==CurrentYCell+1)){
      if (MouseDirection ==0){
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Nf");
        //     Serial.println("");
      }
      if (MouseDirection ==1){
        MouseDirectionList[MouseDirectionListCounter]=2;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Nr");
        //     Serial.println("");
      }
      if (MouseDirection ==2){
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Nb");
        //     Serial.println("");
      }
      if (MouseDirection ==3){
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Nl");
        //     Serial.println("");
      }
      MouseDirection =0;
    }

    //EAST
    if ((NextXCell==CurrentXCell+1) && (NextYCell==CurrentYCell)){
      if (MouseDirection ==0){
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1;  
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Ef");
        //     Serial.println("");
      }
      if (MouseDirection ==1){
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Er");
        //     Serial.println("");
      }
      if (MouseDirection ==2){
        MouseDirectionList[MouseDirectionListCounter]=2;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Eb");
        //     Serial.println("");
      }
      if (MouseDirection ==3){
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("El");
        //     Serial.println("");
      }
      MouseDirection =1;
    }

    //SOUTH
    if ((NextXCell==CurrentXCell) && (NextYCell==CurrentYCell-1)){
      if (MouseDirection ==0){
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1;  
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1; 
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Sf");
        //     Serial.println("");
      }
      if (MouseDirection ==1){
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1; 
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Sr");
        //     Serial.println("");
      }
      if (MouseDirection ==2){
        MouseDirectionList[MouseDirectionListCounter]=0;
        //     MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Sb");
        //     Serial.println("");
      }
      if (MouseDirection ==3){
        MouseDirectionList[MouseDirectionListCounter]=2;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Sl");
        //     Serial.println("");
      }
      MouseDirection =2;   
    }

    //WEST
    if ((NextXCell==CurrentXCell-1) && (NextYCell==CurrentYCell)){
      if (MouseDirection ==0){
        MouseDirectionList[MouseDirectionListCounter]=2;
        MouseDirectionListCounter=MouseDirectionListCounter+1;  
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Wf");
        //     Serial.println("");
      }
      if (MouseDirection ==1){
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1; 
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1; 
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Wr");
        //     Serial.println("");
      }
      if (MouseDirection ==2){
        MouseDirectionList[MouseDirectionListCounter]=1;
        MouseDirectionListCounter=MouseDirectionListCounter+1; 
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Wb");
        //     Serial.println("");
      }
      if (MouseDirection ==3){
        MouseDirectionList[MouseDirectionListCounter]=0;
        MouseDirectionListCounter=MouseDirectionListCounter+1;
        //     Serial.print("\t");
        //     Serial.print("Wl");
        //     Serial.println("");
      }
      MouseDirection=3;
    }
  } 

  //  Serial.println("");
  //  Serial.print(MouseDirectionListCounter);
  //  Serial.println("");



  //Terminate Direction list with a terminator character '9'
  MouseDirectionList[MouseDirectionListCounter]=9;

  //Serial.println("");
  //for (int RouteCounter=0; RouteCounter <= MouseDirectionListCounter; RouteCounter++){
  //  Serial.print(MouseDirectionList[RouteCounter]);
  //  Serial.println("");
  //}
  
  int *DirectionListPointer = MouseDirectionList;
  
  return *DirectionListPointer;
}

The SpeedRunRoute function is defined as returning an int. The implementation does not include a return statement, so no int is returned.

Regardless, you are then trying to store that value into an array of ints sized to hold 512 ints. I predict that that will not work.

The function is also defined as taking two two dimensional arrays. Yet, you are calling it with just two ints, the int at HorizontalWalls[16][17], and the one at VerticalWalls[17][16].

I think that the call to the function should look like:

solvegrid.SpeedRunRoute(HorizontalWalls, VerticalWalls);

What errors are you getting?

Unless you’re using a Mega, I predict all kinds of errors that aren’t going to show up until runtime - you need to reduce the size of those arrays, either by having fewer elements, or by making the elements smaller. (i.e. bits, instead of bytes.)

I'm using the mega, and the code works when run internally, but when I convert it to a header and a library, it breaks. Not sure why, and my pointers don't seem to help...