Question

I am using a recent 1.5.2 version of the POCO C++ Libraries for a project, and every time I compile my project I get the above "error" in POCO code. I say "error" because they appear as errors, but they do not prevent me from compiling, linking, or executing my project.

The errors appear in "Foundation/include/poco/alignment.h":

POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(512);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1024);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2048);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4096);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8192);

Lower values (16, 32, 64, 128) do not produce errors.

I have two questions:

  1. What exactly is the above code trying to do?
  2. Why are they producing errors and how do I get rid of them?

I am building POCO using buildwin.cmd with the following configuration:

VS_VERSION 100
ACTION build
LINKMODE static_mt
CONFIGURATION both
PLATFORM Win32
Was it helpful?

Solution

It's a little hard to see without seeing the actual "errors" (if compilation succeeds, they're not compiler errors, but see below), but the macro is defined thus:

#define POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \
    template <> struct AlignedCharArrayImpl<x> \
    { \
        char aligned alignas(x); \
    }
    #define POCO_HAVE_ALIGNMENT
#endif

In other words, it attempts to create some template alignment structure definitions, such as AlignedCharArrayImpl<16> and AlignedCharArrayImpl<8192>. The error is probably due to passing an invalid alignment to alignas, based on your title of Invalid alignment specifier value.

However, in this case, your code shouldn't actually compile since C++11 7.6.2 explicitly states that unsupported alignments make the program ill-formed. Short of seeing the actual error messages, I can't help with that particular aspect.

I also have little experience with the Microsoft C++ product (I use C# mostly) but this page seems to indicate "less that complete" support for alignas:

Neither Visual C++ 2010 nor Visual C++ in Visual Studio 2012 implement the Core Language keywords alignas/alignof from the alignment proposal that was voted into the Working Paper. Visual C++ 2010 had aligned_storage from TR1. Visual C++ in Visual Studio 2012 adds aligned_union and std::align() to the Standard Library.

I don't know if anything's changed since that was published but there's also at least one bug report on lack of support for this feature, which has been closed as deferred (meaning, presumably, not yet fixed). So it may be that which is causing your issues.


And, based on your comment that it's only Intellisense complaining about the alignment, I believe that was covered in this bug report:

We use separate compilers for IntelliSense and build and, unfortunately, they disagree on the upper limit for alignment.

In other words, provided your compiler is compiling it, you can safely ignore the Intellisense error. Apparently, Microsoft's definition of IDE isn't quite as "integrated" as we have come to expect :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top