[ITK] [ITK-dev] Problems with Change in itkStaticConstMacro
Luc Hermitte
luc.hermitte at c-s.fr
Wed Jan 20 04:39:05 EST 2016
Le 20/01/2016 09:57, Luc Hermitte a écrit :
> Hello,
>
> Le 19/01/2016 21:19, Bradley Lowekamp a écrit :
>> Hello,
>>
>> My release builds for SimpleITK are having significant problems with the
>> change done here [1] to the itkStaticConstMacro.
>>
>> My builds on Redhat 5, with gcc 5.1, are filling my disk with errors
>> along the following:
>> [...]
> [...]
>> I’ll look into alternatives...
>
> Can you isolate the error on a simple test case that reproduce the issue?
I've tried the file attached on https://ideone.com/SGlJ1i but it seems
valid with GCC 5.1.
However, in C++11, constexpr is required. And my g++ 4.8.2, and clang++
as well, tell me:
|| g++ -std=c++03 -Werror -Wall -pedantic extern-templ.cpp -o
extern-templ
extern-templ.cpp|19 col 24| error: ISO C++ 1998 forbids the use of
'extern' on explicit instantiations [-Werror=pedantic]
|| extern template struct Bar<Foo<int>, Foo<double> >;
What differs in SimpleITK source code?
--Luc
-------------- next part --------------
#include <iostream>
#if 0
# define CONSTEXPR constexpr
#else
# define CONSTEXPR
#endif
template <typename T> struct Foo {
typedef T Type;
static const CONSTEXPR std::size_t k_Dim = sizeof(T);
};
template <typename I, typename O> struct Bar {
static const CONSTEXPR std::size_t k_IDim = I::k_Dim;
static const CONSTEXPR std::size_t k_ODim = O::k_Dim;
};
// declare
extern template struct Bar<Foo<int>, Foo<double> >;
// ----< end of .h
// define in one TU
template struct Bar<Foo<int>, Foo<double> >;
// use, in another TU
int main ()
{
typedef Bar<Foo<int>, Foo<double> > Type;
std::cout << Type::k_IDim << " -- " << Type::k_ODim << "\n";
}
-------------- next part --------------
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-developers
More information about the Community
mailing list