【发布时间】:2017-08-13 21:15:43
【问题描述】:
我在通过 ARM 开发人员命令提示符编译 VS2013、MS2015 和 VS2017 下的程序时遇到问题。根据<stdint.h> 和<arm_neon.h> 的文档,标题是正确的。
有什么问题,我该如何解决?
这是程序存根。 full program works 在其他编译器下没问题。
#include <stdint.h>
#include <arm_neon.h>
static const uint32_t K[] =
{
0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5
/* ... more constants in real code ... */
};
uint32_t state[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
uint32_t data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int main(int argc, char* argv[])
{
uint32x4_t STATE0, STATE1, ABEF_SAVE, CDGH_SAVE;
uint32x4_t MSG0, MSG1, MSG2, MSG3;
uint32x4_t TMP0, TMP1, TMP2;
STATE0 = vld1q_u32(&state[0]);
STATE1 = vld1q_u32(&state[4]);
/* Load message */
MSG0 = vld1q_u32((const uint32_t *)(data + 0));
MSG1 = vld1q_u32((const uint32_t *)(data + 16));
MSG2 = vld1q_u32((const uint32_t *)(data + 32));
MSG3 = vld1q_u32((const uint32_t *)(data + 48));
/* Reverse for little endian */
MSG0 = vreinterpretq_u32_u8(vrev32q_u8(vreinterpretq_u8_u32(MSG0)));
MSG1 = vreinterpretq_u32_u8(vrev32q_u8(vreinterpretq_u8_u32(MSG1)));
MSG2 = vreinterpretq_u32_u8(vrev32q_u8(vreinterpretq_u8_u32(MSG2)));
MSG3 = vreinterpretq_u32_u8(vrev32q_u8(vreinterpretq_u8_u32(MSG3)));
TMP0 = vaddq_u32(MSG0, vld1q_u32(&K[0x00]));
/* Rounds 0-3 */
MSG0 = vsha256su0q_u32(MSG0, MSG1);
TMP2 = STATE0;
TMP1 = vaddq_u32(MSG1, vld1q_u32(&K[0x04]));
STATE0 = vsha256hq_u32(STATE0, STATE1, TMP0);
STATE1 = vsha256h2q_u32(STATE1, TMP2, TMP0);
MSG0 = vsha256su1q_u32(MSG0, MSG2, MSG3);
return 0;
}
错误信息如下。第 37-42 行是 /* Rounds 0-3 */ 部分。
C:\Users\Test\SHA-Intrinsics>cl.exe /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP msvc-arm.c
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for ARM
Copyright (C) Microsoft Corporation. All rights reserved.
msvc-arm.c
msvc-arm.c(37) : error C2440: '=' : cannot convert from 'int' to 'uint32x4_t'
msvc-arm.c(40) : error C2440: '=' : cannot convert from 'int' to 'uint32x4_t'
msvc-arm.c(41) : error C2440: '=' : cannot convert from 'int' to 'uint32x4_t'
msvc-arm.c(42) : error C2440: '=' : cannot convert from 'int' to 'uint32x4_t'
VS2017 似乎比 VS2013 和 VS2015 更破:
**********************************************************************
** Visual Studio 2017 RC Developer Command Prompt v15.0
** Copyright (c) 2016 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64_arm'
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Buil
d>cd C:\Users\Test\SHA-Intrinsics
C:\Users\Test\SHA-Intrinsics>cl.exe /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP msvc-arm.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.10.24728 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
msvc-arm.c
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.
10.24728\include\arm_neon.h(17): fatal error C1189: #error: This header is spec
ific to ARM targets
【问题讨论】:
标签: c visual-studio arm intrinsics