Deprecated Declaration Warnings

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Deprecated Declaration Warnings

Post by jnxd »

I've been getting -Wdeprecated-declarations for some time now, for example the following.

Code: Select all

In file included from /usr/include/opencascade/NCollection_IndexedDataMap.hxx:23,
                 from /usr/include/opencascade/Standard_Dump.hxx:17,
                 from /usr/include/opencascade/NCollection_Vec2.hxx:20,
                 from /usr/include/opencascade/NCollection_Vec3.hxx:20,
                 from /usr/include/opencascade/NCollection_Vec4.hxx:18,
                 from /usr/include/opencascade/NCollection_Mat4.hxx:19,
                 from /usr/include/opencascade/gp_Trsf.hxx:21,
                 from /usr/include/opencascade/gp_Trsf2d.lxx:15,
                 from /usr/include/opencascade/gp_Trsf2d.hxx:244,
                 from /usr/include/opencascade/gp_Dir2d.lxx:21,
                 from /usr/include/opencascade/gp_Dir2d.hxx:274,
                 from /usr/include/opencascade/gp_Vec2d.lxx:18,
                 from /usr/include/opencascade/gp_Vec2d.hxx:318,
                 from /usr/include/opencascade/gp_Pnt2d.lxx:19,
                 from /usr/include/opencascade/gp_Pnt2d.hxx:175,
                 from /usr/include/opencascade/TColgp_HArray1OfPnt2d.hxx:20,
                 from /usr/include/opencascade/Geom2d_BSplineCurve.hxx:28,
                 from /.../src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp:25:
/usr/include/opencascade/NCollection_StlIterator.hxx:30:15: warning: ‘template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator’ is deprecated [-Wdeprecated-declarations]
   30 |   public std::iterator<Category, ItemType, ptrdiff_t,
      |               ^~~~~~~~
In file included from /usr/include/c++/12.1.0/bits/stl_algobase.h:65,
                 from /usr/include/c++/12.1.0/bits/specfun.h:45,
                 from /usr/include/c++/12.1.0/cmath:1935,
                 from /usr/include/opencascade/Standard_Real.hxx:18,
                 from /usr/include/opencascade/Standard_PrimitiveTypes.hxx:25,
                 from /usr/include/opencascade/Standard_Transient.hxx:20,
                 from /usr/include/opencascade/Standard.hxx:91,
                 from /usr/include/opencascade/Geom2d_BSplineCurve.hxx:20:
/usr/include/c++/12.1.0/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
Anyone has an idea what's happening and what can be done about it? I suspect updating OCC might help, but I don't see a newer version on Manjaro and I'd prefer not to compile OCCT just for this purpose.
My latest (or last) project: B-spline Construction Project.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Deprecated Declaration Warnings

Post by jnxd »

@wmayer @Kunda1 @uwestoehr any idea of this?
My latest (or last) project: B-spline Construction Project.
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Deprecated Declaration Warnings

Post by wmayer »

Some of the std::iterator classes cannot be used as sub-class for own iterator implementations any more. To solve the warnings all what needs to be done is to define the types iterator_category, value_type, difference_type, pointer and reference. I once did this for the PyCXX sources (git commit 4547e989e).
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Deprecated Declaration Warnings

Post by jnxd »

wmayer wrote: Sat Jul 30, 2022 3:05 pm Some of the std::iterator classes cannot be used as sub-class for own iterator implementations any more. To solve the warnings all what needs to be done is to define the types iterator_category, value_type, difference_type, pointer and reference. I once did this for the PyCXX sources (git commit 4547e989e).
Is this supposed to be done in stl_algobase and OCC then? I am not able to see where else I could do this within the freecad code.
My latest (or last) project: B-spline Construction Project.
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Deprecated Declaration Warnings

Post by wmayer »

Is this supposed to be done in stl_algobase and OCC then? I am not able to see where else I could do this within the freecad code.
It must be done in the OCC sources. The warning is raised because some custom iterator classes are derived from the deprecated classes.

To fix the warning one has to add a few public typedefs to the custom iterator class. But because OCC headers cause the warning it's best to report a bug in the OCC tracker.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Deprecated Declaration Warnings

Post by jnxd »

wmayer wrote: Mon Nov 07, 2022 3:17 pm
Is this supposed to be done in stl_algobase and OCC then? I am not able to see where else I could do this within the freecad code.
It must be done in the OCC sources.
Probably also in whatever package provides /usr/include/c++/12.1.0/bits/stl_algobase.h. But for now it's not in our control so I guess I'm just gonna have to suppress the warnings.
My latest (or last) project: B-spline Construction Project.
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Deprecated Declaration Warnings

Post by wmayer »

Probably also in whatever package provides /usr/include/c++/12.1.0/bits/stl_algobase.h. But for now it's not in our control so I guess I'm just gonna have to suppress the warnings.
I can hardly imagine that the STL implementation deprecates a feature in one part and uses this feature in another part of it.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Deprecated Declaration Warnings

Post by jnxd »

wmayer wrote: Mon Nov 07, 2022 7:48 pm
Probably also in whatever package provides /usr/include/c++/12.1.0/bits/stl_algobase.h. But for now it's not in our control so I guess I'm just gonna have to suppress the warnings.
I can hardly imagine that the STL implementation deprecates a feature in one part and uses this feature in another part of it.
You're right. Reading more carefully I see that it just says that is where the "std::iterator" class was declared. This is all OCC.
My latest (or last) project: B-spline Construction Project.
Post Reply