# Build error C4996 in vtkUnstructuredGrid.h after Visual Studio update (VTK 9.6)

**URL:** https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470
**Category:** Support
**Tags:** code
**Created:** [June 23, 2026, 9:38am UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470 "2026-06-23T09:38:19Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![CharInt0](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charint0/32/2983_2.png) [@CharInt0](https://discourse.vtk.org/u/CharInt0)
#### Post date: [June 23, 2026, 9:38am UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/1 "2026-06-23T09:38:19Z")

</div>

**OS:** Windows 11

**VTK Version:** 9.6

**Compiler:** Visual Studio Professional 2026 (v18.7.1)

Hi everyone,

Since updating Visual Studio to the latest version, my C++ project using VTK 9.6 has stopped compiling. I am encountering the following build error:

Common\DataModel\vtkUnstructuredGrid.h(134,8): error C4996: ‘vtkDataSet::GetCellTypes’: Use GetDistinctCellTypes(vtkCellTypes\* types) instead.

searched my entire project but could not find any explicit calls to `GetCellTypes` in my code, so I suspect this warning/error is originating internally from another VTK file.

The only part of my codebase that utilizes `vtkUnstructuredGrid` is the following snippet, which makes me think the issue might be triggered when interacting with `vtkGeometryFilter`:

```
`auto plusSource = vtkSmartPointer<vtkGlyphSource2D>::New();
plusSource->SetGlyphTypeToCross();
m_glyphSources.insert({ GlyphTypes::Plus, plusSource });

std::vector<std::array<double, 3>> truncPyramidCoord;
truncPyramidCoord.push_back({ {-0.5, -0.5, 0.0} }); // Bottom Face
truncPyramidCoord.push_back({ {0.5, -0.5, 0.0} });
truncPyramidCoord.push_back({ {0.5, 0.5, 0.0} });
truncPyramidCoord.push_back({ {-0.5, 0.5, 0.0} });
truncPyramidCoord.push_back({ {-0.3, -0.3, 1.0} }); // Top Face
truncPyramidCoord.push_back({ {0.3, -0.3, 1.0} });
truncPyramidCoord.push_back({ {0.3, 0.3, 1.0} });
truncPyramidCoord.push_back({ {-0.3, 0.3, 1.0} });
vtkNew<vtkPoints> truncPyramidPoints;
vtkNew<vtkHexahedron> hexahedron;
for (auto i = 0; i < truncPyramidCoord.size(); ++i)
{
	truncPyramidPoints->InsertNextPoint(truncPyramidCoord[i].data());
	hexahedron->GetPointIds()->SetId(i, i);
}
vtkNew<vtkUnstructuredGrid> truncPyramidUGrid;
truncPyramidUGrid->SetPoints(truncPyramidPoints);
truncPyramidUGrid->InsertNextCell(hexahedron->GetCellType(), hexahedron->GetPointIds());
auto truncated_pyramid = vtkSmartPointer<vtkGeometryFilter>::New();
truncated_pyramid->SetInputData(truncPyramidUGrid);
m_glyphSources.insert({ GlyphTypes::TruncatedPyramid, truncated_pyramid });`

```

As workarounds, I have already tried adding `#define VTK_LEGACY_SILENT` at the very top of my source (`.cpp`) files, my engine header file before any other include directives. Unfortunately, the error persists.

Has anyone encountered this problem recently with the latest MSVC updates, and is there a known fix or workaround for it?

Thank you in advance for your help!  
C.R.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [June 23, 2026, 9:44am UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/2 "2026-06-23T09:44:56Z")

</div>

@spyridon97 wdyt ?

@CharInt0 did you rebuild VTK yourself using the same compiler ?

---

<div class="post-metadata">

### Author: ![CharInt0](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charint0/32/2983_2.png) [@CharInt0](https://discourse.vtk.org/u/CharInt0)
#### Post date: [June 23, 2026, 9:54am UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/3 "2026-06-23T09:54:39Z")

</div>

No, I am using a pre-compiled version of VTK 9.6 that was built with an older version of Visual Studio.

Since I just updated my local Visual Studio to version 18.7.1, my project is using the new compiler, but it is still pointing to those older VTK binaries and include paths.

Do I need to completely clear my build directory and rebuild the VTK source code from scratch using this new version of Visual Studio to fix the error?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [June 23, 2026, 9:56am UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/4 "2026-06-23T09:56:32Z")

</div>

> [@CharInt0](#):
>
> Do I need to completely clear my build directory and rebuild the VTK source code from scratch using this new version of Visual Studio to fix the error?

While I cannot ensure it will fix the error, this is where I would start.

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spyridon97/32/7069_2.png) [@spyridon97](https://discourse.vtk.org/u/spyridon97)
#### Post date: [June 23, 2026, 12:48pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/5 "2026-06-23T12:48:32Z")

</div>

I have no clue what could have caused that. I suggest building from source.

---

<div class="post-metadata">

### Author: ![CharInt0](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charint0/32/2983_2.png) [@CharInt0](https://discourse.vtk.org/u/CharInt0)
#### Post date: [June 23, 2026, 1:00pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/6 "2026-06-23T13:00:04Z")

</div>

Mathieu and [Spiros Tsalikis](https://discourse.vtk.org/u/spyridon97), thank you for the suggestions.

I completely wiped my build directory and did a fresh build of the VTK 9.6 source code from scratch using the new Visual Studio 2026 compiler toolset (`MSVC 18.7.8.30822`, targeting `x64`).

The CMake configuration and generation completed successfully, Then the VTK 9.6 actually compiled successfully too with the new compiler toolset. However, when I tried to recompile my project, which links dynamically to the newly built VTK libraries, the **build failed with the same**  **error** :

```auto
1>C:\VTK\VTK-src\Common\DataModel\vtkUnstructuredGrid.h(134,8): error C4996: 'vtkDataSet::GetCellTypes': Use GetDistinctCellTypes(vtkCellTypes* types) instead.

```

Even though I rebuilt VTK with the same compiler, whenever my project includes `vtkUnstructuredGrid.h`, the compiler treats the deprecated `GetCellTypes` warning as a hard error. As mentioned before, adding `#define VTK_LEGACY_SILENT` in my project headers or precompiled headers (`pch.h`) did not bypass it.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [June 23, 2026, 1:04pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/7 "2026-06-23T13:04:55Z")

</div>

Sounds like a bug in VTK with VS 2026, please open an issue: [https://gitlab.kitware.com/paraview/paraview/-/work\_items](https://gitlab.kitware.com/paraview/paraview/-/work_items)

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spyridon97/32/7069_2.png) [@spyridon97](https://discourse.vtk.org/u/spyridon97)
#### Post date: [June 23, 2026, 1:04pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/8 "2026-06-23T13:04:57Z")

</div>

So i see something that may be problematic

 ![image](https://discourse.vtk.org/uploads/default/original/2X/9/960775f23e8ceed0827388de42149fade51566f9.jpeg)

both classes deprecate the same function, and implement it the same way.

Could you try to remove the function definition and deprecation of GetCellTypes from vtkUnstructuredGrid.h  
recompile and tell us if it fixed the error?

---

<div class="post-metadata">

### Author: ![CharInt0](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charint0/32/2983_2.png) [@CharInt0](https://discourse.vtk.org/u/CharInt0)
#### Post date: [June 23, 2026, 3:04pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/9 "2026-06-23T15:04:35Z")

</div>

> [@spyridon97](#):
>
> both classes deprecate the same function, and implement it the same way.
> 
> Could you try to remove the function definition and deprecation of GetCellTypes from vtkUnstructuredGrid.h  
> recompile and tell us if it fixed the error?

I followed your suggestion and commented out the deprecated function definition from `vtkUnstructuredGrid.h` like this:

C++

```auto
// VTK_DEPRECATED_IN_9_6_0("Use GetDistinctCellTypes(vtkCellTypes* types) instead.")
// void GetCellTypes(vtkCellTypes* types) override { this->GetDistinctCellTypes(types); }

```

After doing this and recompiling VTK 9.6, my project now compiles successfully without any errors. The conflict between the duplicate deprecations in `vtkDataSet` and `vtkUnstructuredGrid` was definitely what was causing the MSVC 18.7.8 compiler to trigger the hard `C4996` error in the client solution.

For some unknown reason now I cannot open open a bug report on the Kitware GitLab repository, the site is hanging after I click “create”.

Thank you all so much for your help,  
C.R.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [June 23, 2026, 3:10pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/10 "2026-06-23T15:10:17Z")

</div>

> [@CharInt0](#):
>
> For some unknown reason now I cannot open open a bug report on the Kitware GitLab repository, the site is hanging after I click “create”.

click here, [https://gitlab.kitware.com/](https://gitlab.kitware.com/) after that it should work.

---

<div class="post-metadata">

### Author: ![CharInt0](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charint0/32/2983_2.png) [@CharInt0](https://discourse.vtk.org/u/CharInt0)
#### Post date: [June 23, 2026, 3:23pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/11 "2026-06-23T15:23:52Z")

</div>

Thank you Mathieu. It worked:

[VTK 9.6 build error C4996 in vtkUnstructuredGrid.h with MSVC 18.7.8 (GetCellTypes deprecation conflict)](https://gitlab.kitware.com/paraview/paraview/-/work_items/23314)

paraview/paraview#23314

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [June 23, 2026, 3:25pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/12 "2026-06-23T15:25:17Z")

</div>

moved to [https://gitlab.kitware.com/vtk/vtk/-/work\_items/20091](https://gitlab.kitware.com/vtk/vtk/-/work_items/20091)

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spyridon97/32/7069_2.png) [@spyridon97](https://discourse.vtk.org/u/spyridon97)
#### Post date: [June 23, 2026, 3:35pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/13 "2026-06-23T15:35:41Z")

</div>

Fix in [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/13352](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/13352).

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 24, 2026, 5:34pm UTC](https://discourse.vtk.org/t/build-error-c4996-in-vtkunstructuredgrid-h-after-visual-studio-update-vtk-9-6/16470/14 "2026-06-24T17:34:43Z")

</div>

C4996 is “use of deprecated item”. I suspect you have MSVC’s equivalent of `-Werror` enabled. It’s not clear where the method is being _used_ to trigger the warning though. Sometimes MSVC instantiation rules end up triggering such warnings…
