[okl4-developer] iguana cc

Jorge Torres jorge.torres.maldonado at gmail.com
Mon May 28 11:33:25 EST 2007


Hi Ben,

Thank you, your extern C wraping advise  was exactly what I was looking
for,  if I only knew this a few minutes ago, I wouldn't have cloned
stdio.hwith extern C for every function, hahaha :), not a big deal
anyway.

The only thing I miss about C++ runtime, its the new method for memory
allocation, I think this is a little off topic for okl4, so feel free to
ignore this: I'm trying to get one NEW for my self, but for now the best
solution I've came up with was adding a new operator for each class:

#define NEW(TYPE) void * operator new (size_t a){    \
        void *p;                \
        p=(TYPE*)malloc(sizeof(TYPE));    \
        return p;                \
    }

class bla{
.
.
public:
NEW(bla);
.
.
};
But I can't figure out how to make this in a much more general way,
something like inline new.
problem I have is on how can one guess what is itself's type so one can do
something like:
void *p=(guessed_itselftype *)malloc(sizeof(guessed_itselftype));
Anyhow, if someone has done this, I'll be happy to know how.


Thanks again,

Jorge


On 5/27/07, Ben Leslie <benno at ok-labs.com> wrote:
>
> On Fri May 25, 2007 at 04:54:20 -0400, Jorge Torres wrote:
> >Hi okl4.org,
> >
> >I tried to change the example/manyelfsegs/src/main.c to main.cc, and I
> had
> >some linking problems with stdio.h, does someone knows what is the
> correct
> >way of doing this (iguana style :), my temporal solution was:
> >-----
> >at this new example/manyelfsegs/src/main.cc
> >#define CTOCPP extern "C"
> >#include <stdio.h>
> >------
> >and at libs/c/include/stdio.h
> >#ifndef CTOCPP
> >#define CTOCPP
> >#endif
> >.
> >.
> >CTOPCPP int printf(const char *, ...);
> >------
>
>
> Hi Jorge,
>
> We don't really have a C++ runtime, but, if you are trying to use the
> C library runtime, within a C++ program you should wrap the include
> within an extern C block, e.g:
>
>
> """
>
> extern C {
>     #include <stdio.h>
> }
>
>
> """
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.okl4.org/pipermail/developer/attachments/20070527/f6e9729e/attachment.htm 


More information about the Developer mailing list