STEPCAFControl_Writer.hxx unknown type name 'NCollection_Vector'

Hello,

I'm having difficulties in compiling my program.

 

My compiler output:

In file included from ../src/STEPModel.cpp:19:
/opt/local/include/opencascade/STEPCAFControl_Writer.hxx:236:3: error: unknown type name 'NCollection_Vector'
  NCollection_Vector<Handle(StepRepr_RepresentationItem)> myGDTAnnotations;
  ^
/opt/local/include/opencascade/STEPCAFControl_Writer.hxx:236:21: error: expected member name or ';' after declaration specifiers
  NCollection_Vector<Handle(StepRepr_RepresentationItem)> myGDTAnnotations;
  ~~~~~~~~~~~~~~~~~~^
1 warning and 2 errors generated.

I'm using currently the macports version (as seen on /opt/local/) but also tried 7.4.0 after build (in /usr/local) on macOS.

The STEPCAFControl_Writer.hxx is exactly the same in both versions.

Developing in Eclipse CDT on macOS (10.12.6) with Apple LLVM version 9.0.0 (clang-900.0.39.2) from XCode.

 

Building OpenCascade is fine and works straight out-of-the-box.

 

Any help is appreciated! Thanks in advance...

-Michael

Kirill Gavrilov's picture

Have you tried putting

#include <NCollection_Vector.hxx>

at the beggining of your code?

Michael Maenz's picture

Hi Kirill,

indeed I didn't as I do not have any use for NCollection_Vector. Now it works and compiles just fine.

But is it on purpose to leave it to the developer to include the header? Shouldn't it be included by STEPCAFControl_Writer itself?

BTW, thanks for your fast reply!! Didn't expect that...

Kirill Gavrilov's picture

This is a common issue in C++ caused by splitting class definition into header and source file and error-prone usage of preprocessor for headers inclusion in specific or arbitrary order.

To workaround the issue, OCCT Coding Rule "Headers order" suggests that class source file should first include header file of class itself, to verify header file self-sustainability.
In case of STEPCAFControl_Writer.cxx this rule is not followed:


#include <BRep_Builder.hxx>
#include <GeomToStep_MakeAxis2Placement3d.hxx>
#include <GeomToStep_MakeCartesianPoint.hxx>
...
#include <STEPCAFControl_Writer.hxx>

so that the issue with missing "#include <NCollection_Vector.hxx>" in STEPCAFControl_Writer.hxx remains unrevealed until application code suddently includes STEPCAFControl_Writer.hxx in specific order.

Fill free to contribute into OCCT by registering a bug and probably providing a trivial (in this case) patch:
https://dev.opencascade.org/index.php?q=home/get_involved