-1

Given this code:

using vec = uint32_t __attribute__ ((vector_size (16)));

How can it be rewritten for MSVC 2015?

vladon
  • 8,158
  • 2
  • 47
  • 91

2 Answers2

4

It's a GCC specific extension for creating integer & float types that are larger than 64 bits, and as far as I know there is no direct replacement in VC++, but there is an __m128d type that you may be able to use instead.

evan
  • 1,463
  • 1
  • 10
  • 13
3

It is an example of the gcc vector extensions which are an abstraction over the SIMD instructions.

This particular line creates a type alias vec for a vector that is a total of 16 bytes long, and consists of 32 bit sized unsigned itegers.

MSVC doesn't appear to have an equivalent extension. The use of SIMD is supported through alignment routines and inline assembly. As such, there is no way to exactly rewrite the line and it is not sufficient to rewrite just this line, but also the lines where the alias or objects using the type, are used.

eerorika
  • 232,697
  • 12
  • 197
  • 326
  • 1
    MSVC provides the [__m128i](https://msdn.microsoft.com/en-us/library/26232t5c.aspx) data type with equivalent layout to that the OP is looking for. Variables of type `__m128i` are also suitably aligned on 16-byte boundaries. The SIMD instructions are supported through [compiler intrinsics](https://msdn.microsoft.com/en-us/library/26td21ds.aspx). The x64 compiler doesn't support inline assembly, and inline assembly is not the recommended way to implement SIMD code. – IInspectable Sep 28 '16 at 12:20