-
-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
itkMacros less robust / break external code that also has an itk namespace #4074
Comments
Thank you for contributing an issue! 🙏 Welcome to the ITK community! 🤗👋☀️ We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜 |
Having a minimal example demonstrating the problem would probably be helpful. @Leengit could you tackle this without a demonstrative example? |
Here's a minimal example: example.cpp: #include <itkLightObject.h>
#include <itkObjectFactory.h>
namespace example
{
namespace itk
{
// These two lines shouldn't be necessary and weren't until ITK v5.3.0.
// Please keep the absolute ::itk namespaces in macros like itkNewMacro().
using LightObject = ::itk::LightObject;
template<typename T> using ObjectFactory = ::itk::ObjectFactory<T>;
class Example : public ::itk::LightObject
{
public:
using Self = Example;
itkTypeMacro(Example, ::itk::LightObject)
itkNewMacro(Self)
protected:
Example() = default;
~Example() override = default;
};
}
} CMakeLists.txt: cmake_minimum_required(VERSION 3.16.3...3.19.7 FATAL_ERROR)
project(Example)
find_package(ITK 5.3 REQUIRED COMPONENTS ITKCommon)
add_library(example example.cpp)
target_link_libraries(example PRIVATE ITKCommon) |
To address resolution in client code. InsightSoftwareConsortium#4074
@thewtex Thanks, it works! Not an issue for us but you may want to consider to do the same for the std namespace in macros. |
To address resolution in client code. InsightSoftwareConsortium#4074
@kislinsk thanks for the verification! Good idea regarding |
Description
In 24e7b45, leading colons for namespaces have been removed with an automated search and replace. Unfortunately this also affected some macros and made them less robust resp. introduced a regression. We have a few projects that also have itk (sub-)namespaces and the lookup for classes like LightObject and ObjectFactory used in macros like itkNewMacro() is now broken in these cases. It is not a compiler-specific issue as it happens on MSVC, gcc, and clang.
Expected behavior
Macros always should be as robust as possible in particular regarding parenthesis or namespaces.
Versions
Worked in ITK v5.2.1, broken in ITK v5.3.0.
Environment
Windows, Ubuntu, macOS, MSVC, GCC, clang.
Additional Information
The text was updated successfully, but these errors were encountered: