Shop OBEX P1 Docs P2 Docs Learn Events
C++ Template Class Too Big for non-eXternal MM? — Parallax Forums

C++ Template Class Too Big for non-eXternal MM?

SyncrosisSyncrosis Posts: 3
edited 2014-02-04 08:58 in Propeller 1
Hi everybody,

I'm trying to create a templated class in C++ for a generic linked list. I am stubbing in the framework for the templated class. Working incrementally, I put in the basics and instantiated an instance of the object. Upon calling the most basic of member functions, the compiler begins to complain at me about exceeding the hub .text region. I'm attempting to build to CMM. I'd like to steer away from XMM if possible - the only real external memory I have access to is an SD card and can't figure out how to load to it. Oh yea, I am not including any standard C++ libraries (at least not on purpose).

Here's my code reduced down, but still overflowing .text. Do you have any suggestions to reduce the binary size?
#include <stdio.h>            // Recommended over iostream for saving space
#include <propeller.h>        // Propeller-specific functions


typedef struct list_s {


  void             *data;
  struct list_s    *prev;
  struct list_s    *next;
} list_t;


template <class T> class LinkList {
  private:
    list_t *front, *back;
    int size;


  public:
    LinkList();
    int Enqueue(T *newObj);
};


//default class constructor
template <class T>
LinkList<T>::LinkList() {


  size = 0;
  front = back = NULL;
}




template <class T>
int LinkList<T>::Enqueue(T *newObj) {


  list_t *newNode = new list_t;


  if(newNode == NULL)
    return false;


  return true;
}




int main(){


  LinkList<int> bob;
  int a = 42;
  
  bob.Enqueue(&a);


  return 0;
}

Thank you so much!

Comments

Sign In or Register to comment.