Re: Warning 303: %extend defined for an undeclared class opencascade::handle.
William S Fulton <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftB19i1OEx_SoLAAXFSyTuag7UsHvvyUtFNH0SpDfM2AXg@mail.gmail.com> |
On Mon, 27 Jul 2020 at 12:56, Kustaa Nyholm <[email protected]> wrote: > > > > On 27 Jul 2020, at 11.18, Kustaa Nyholm <[email protected]> > wrote: > > > > I get the 303 for following, although the test_ball seems to compile > fine? > > > > I just can't figure this out. > > > > > > %{ > > #include <Standard_Transient.hxx> > > > > opencascade::handle<int> test_ball; > > > > %} > > > > %extend opencascade::handle > > { > > > > }; > > > > I've looked into Standard_Transient.hxx and there handle is forward > declared as: > > > > namespace opencascade { > > template <class T> class handle; > > } > > > > I cannot seem to find the actual class def for handle though. > > > > wbr Kusti > > > > Found the actual class def and I think I know how to solve this, but > I still not understand why the above does not work. > > You have correctly observed that you have a forward class declaration but no definition, SWIG should really technically warn: Warning 303: %extend defined for an undefined class opencascade::handle rather than: Warning 303: %extend defined for an undeclared class opencascade::handle in this case, subtle difference! > First of all I figure I should be working on class 'Standard_Handle', not > handle, > but to make it work I need to introduce Standard_Handle to SWIG like this: > > > class Standard_Handle { > Standard_Handle()=0; > }; > The above is not valid C++, so I wouldn't much to work! > %ignore operator Standard_Transient*(); > > %extend Standard_Handle > { > operator Standard_Transient* () > { > return static_cast<Standard_Transient*>(this); > } > > }; > > > And this is because the actual header that contains the declaration is > never seen by > SWIG cause I'm / the SWIG .i files I'm working on do not feed that/those > headers to it, right? > The include above is only processed by the C++ compiler. > > Ok, so above produces no warnings, however it does not fix the actual > problem > I'm having but I will make an other post of it. > > I suggest reading the SWIG Basics chapter at http://swig.org/Doc4.0/SWIG.html. It should describe the areas which aren't clear to you; namely the differences between %include, #include, what SWIG parses, the SWIG preprocessor and C preprocessor. William _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user