Problem using Wormhole with STL

7 posts / 0 new
Last post
narek
narek's picture
Offline
Joined: 4 Jan 2012
Posts:
Problem using Wormhole with STL

When I include both STL and Wormhole headers I get the following compilation error.

c:/MoSync/include/newlib/malloc.h:39: error: declaration of C function `void* malloc(size_t)' conflicts with c:/MoSync/include/maheap.h:56: error: previous declaration `void* malloc(int)' here

c:/MoSync/include/newlib/malloc.h:55: error: declaration of C function `void* realloc(void*, size_t)' conflicts with c:/MoSync/include/maheap.h:92: error: previous declaration `void* realloc(void*, int)' here

c:/MoSync/include/newlib/malloc.h:63: error: declaration of C function `void* calloc(size_t, size_t)' conflicts with c:/MoSync/include/maheap.h:69: error: previous declaration `void* calloc(int, int)' here

 

My test source file looks like this:

#include <string>
#include <Wormhole/WebViewMessage.h>

 

Is this a known issue?

Thanks!

Narek

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Yeah, I'm not an expert on newlib, but I think that you can't use both newlib and 'standard' MoSync libraries like maheap, which wormhole probably uses. I'll ask around.

narek
narek's picture
Offline
Joined: 4 Jan 2012
Posts:

Thanks for your help Sam!

I could workaround the compilation error by reorganizing the code, so that now the STL dependent code and Wormhole dependent codes are in different source files. But after that I started to get linker errors as there are multiple definitions of these symbols.

This means that LibC and STL can be used only in very limited types of applications that don’t have any dependencies to MAStd (standard Mosync library). If I’m not wrong Wormhole is not the only library that uses MAStd.

Hope this issue is resolved in near future as this seems a major limitation to me.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Yeah, newlib is er, new. Its only really possible since 'dead code elimination' has been built as the libraries were far too large for many devices. Many STL/LibC functions have equivalents in the MoSync standard library though. Are you porting existing C code?

narek
narek's picture
Offline
Joined: 4 Jan 2012
Posts:

Yes. I was trying to compile existing C++ code that uses STL. It does not use LibC directly, but STLPort does.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

There are a lot of functions of STL which do have MoSync equivalents - can I help port the code?

narek
narek's picture
Offline
Joined: 4 Jan 2012
Posts:

Thanks Sam! There is no need to port code. I was trying to understand how good the support for the standard library is.