-->
Page 4 of 4

Re: using std::iostream, std::vector

PostPosted: Fri Jan 09, 2015 7:24 am
by igrr
There's no need to "mess" with them, just define them somewhere in your project (inside a .cpp file):

Code: Select allvoid *operator new(size_t size) {
  return os_malloc(size);
}

void *operator new[](size_t size) {
  return os_malloc(size);
}

void operator delete(void * ptr) {
  os_free(ptr);
}

void operator delete[](void * ptr) {
  os_free(ptr);
}

extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
extern "C" void abort() {
  while(true); // enter an infinite loop and get reset by the WDT
}

void __cxa_pure_virtual(void) {
  abort();
}

void __cxa_deleted_virtual(void) {
  abort();
}

Re: using std::iostream, std::vector

PostPosted: Fri Jan 09, 2015 3:02 pm
by mog
Thank you @igrr

After some trial and error I was able to compile the source which is attached to this post. I've had to remove upgrade_ssl from LIBS in Makefile since it's missing and I don't know where to get it from nor I don't yet know what I'd need it for.
One thing I've found strange is that after pasting your code I've had problems with pvPortMalloc and vPortFree not being defined. After some search I've found that they were supposed to be defined in mem.h but were commented out:

Code: Select all#ifndef __MEM_H__
#define __MEM_H__

//void *pvPortMalloc( size_t xWantedSize );
//void vPortFree( void *pv );
//void *pvPortZalloc(size_t size);

#define os_malloc   pvPortMalloc
#define os_free     vPortFree
#define os_zalloc   pvPortZalloc

#endif


After uncommenting I've compiled the code so I don't know why they were actually removed. Because of that I've also added source from mem.h into my cpp file.

I still haven't tested if the code executes properly but thanks to your help I was able to compile it! :)
Regarding the attached code I've added an additional other_functions.c file to test if I'd be able to call os_printf which I'd really like to use for debugging purposes.