[Insight-developers] Clang Warnings about in-class static initializers...

Williams, Norman K norman-k-williams at uiowa.edu
Fri Dec 16 17:27:07 EST 2011


Here's the problem:  VCL_STATIC_CONST_INIT_INT is set based on running a
small program that succeeds if the compiler accepts in-class static const
initialization, and fails if they do not.


So GCC by default supports it as an extension, and it's defined to 1.
Other compilers will fail to compile the little test program, and it will
be set to 0.

If VCL_STATIC_CONST_INIT_INT is set to zero, no problem -- then the
constants are declared in the vnl_math.h, but defined in vnl_math.cxx, and
all is right with the world.

CLang takes a different approach -- it will compile successfully but
complain.  So VCL_STATIC_CONST_INIT_INT is set to 1 meaning that every
translation unit that includes vnl_math.h (in ITK, that means nearly all
of them), is going to throw a warning for every static float member
defined in the header.

So the solution might not require mucking around with VNL at all -- if
there's a CLang compiler flag we can turn on that will make that GCC
extension an error instead of a warning, VNL's configuration stage will
generate a vnl_compiler_config.h that will get rid of the bazillion
warnings.

On 12/16/11 4:18 PM, "Sean McBride" <sean at rogue-research.com> wrote:

>On Fri, 16 Dec 2011 19:37:01 +0000, Williams, Norman K said:
>
>>What could remedy the situation without involving any modifications to
>>VNL
>>would be if theres a way to force VCL_STATIC_CONST_INIT_INT to be false/0
>>when CLang is used.
>
>Why only when clang is used?  It may be accepted by other compilers, but
>it's not valid C++03.  Or does ITK require a C++11 compiler?  Or do we
>just be lax with this since it's now part of C++11 and already silently
>accepted by most compilers?
>
>--
>____________________________________________________________
>Sean McBride, B. Eng                 sean at rogue-research.com
>Rogue Research                        www.rogue-research.com
>Mac Software Developer              Montréal, Québec, Canada
>
>



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the Insight-developers mailing list