View Issue Details

IDProjectCategoryView StatusLast Update
0004560Slicer4Core: Base Codepublic2018-05-29 22:50
ReporterphcerdanAssigned Tojcfr 
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status assignedResolutionopen 
Product Version 
Target VersionSlicer 4.11.0Fixed in Version 
Summary0004560: C++11: Modernize NULL and 0 to nullptr
Description

ITK5.0 uses c++11 nullptr instead of NULL and 0.
I was getting errors explained here: https://marcofoco.com/use-nullptr-if-you-can-0-if-you-need-but-please-dont-use-null/
error: call to 'a' is ambiguous

STEPs to use clang-tidy:
Generate compile_commands.json with CMake option: -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON.
This generates a compile_commands.json in your build directory at configure time.

install clang and clang tools, that includes clang-tidy and run-clang-tidy.py.
(In Archlinux: sudo pacman -S clang, in other systems might be clang-extra-tools or similar)
Docs: http://clang.llvm.org/extra/clang-tidy/

And in the build folder of slicer, execute:
run-clang-tidy.py -header-filter='.*' -checks='-*,modernize-use-nullptr' -fix
This will iteratively check files for updates. It takes a while. The sources are only modified at the end of the process, so you could cancel anytime before with no consequences.

Steps To Reproduce

Easy way: Use ITK_DIR to point to ITK5

Additional Information

It is not perfect, so there are cases where manual substitution is required, also it doesn't work on comments.
Extra steps:
:s/NULL/nullptr/c
Files:
Libs/vtkITK/vtkITKArchetypeImageSeriesReader.cxx
Libs/RemoteIO/vtkHTTPHandler.cxx
:s/0/nullptr/c
Libs/MRML/Core/vtkITKTransformConverter.h
Libs/MRML/Core/vtkMRMLTransformStorageNode.cxx

TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2018-05-22 11:12 phcerdan New Issue
2018-05-22 11:12 phcerdan Status new => assigned
2018-05-22 11:12 phcerdan Assigned To => jcfr
2018-05-22 11:56 phcerdan Description Updated View Revisions
2018-05-29 22:50 lassoan Target Version => Slicer 4.11.0