octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoid global pointers in dae


From: Francesco Faccio
Subject: Re: Avoid global pointers in dae
Date: Mon, 15 Aug 2016 20:38:52 +0000

Carlo De Falco wrote:

> On 15 Aug 2016, at 12:42, Francesco Faccio <address@hidden> wrote:
>
> > This is nice, but I can't write methods that compute residual inside my class. I need to call method do_multi_index_op or feval, which are defined in libinterp. That's why I dereference pointres to call function defined in [1] line 72.
>
> Can't you create a method that calls feval internally,
> and pass a pointer to it with the standard technique shown
> in the previous email?

Finally I did it and it works without global pointers! 

The complication was this:
since libinterp (where classes octave_value, octave_function etc. are defined) depends on liboctave (where classes for corefcn and dld-fcn are defined), there is no way to include the headers required (ov.h, ov-fcn.h and others from libinterp/octave-value) for calling their methods.

You can see here the dependences of libinterp and here those of liboctave.

What I can do inside my class after a forward declaration is:
- declare a member of the class which is a pointer or reference to the incomplete type
-define functions which accepts/returns pointers or references to the incomplete type, but without using their methods

In my class I cannot store a member octave_function , because the compiler doesn't know anything about that type and I got:

error: aggregate ‘octave_function e’ has incomplete type and cannot be defined


And I cannot call directly a method of an incomplete time in any method, static or not, of my class.
Fortunately, I can store a pointer to the incomplete type and pass it as a parameter to the function:

ColumnVector res = (*funct) (y0, yp0, t, ires, ida_fun);

where ida_fun is the pointer to the incomplete type.
I dont' know if it was clear what was the complication here. I used the technique you suggested and it made the code a lot more simple than using lambdas.

Francesco


reply via email to

[Prev in Thread] Current Thread [Next in Thread]