错误预期';'在cuda建立解决方案时

时间:2017-01-24 09:40:46

标签: cuda aes

我正在尝试使用c在cuda中进行加密解密。我下载了代码,但是在构建解决方案的同时。它给出错误预期';'我评论为// HERE代码中的错误。我尝试过,但无法找到解决方案。我下载的代码看起来像。

uint32_t sw(uint32_t word)
{
    union {
        uint32_t word;
        uint8_t bytes[4];
    } subWord  __attribute__ ((aligned));//HERE
    subWord.word = word;

    subWord.bytes[3] = s_h[subWord.bytes[3]];
    subWord.bytes[2] = s_h[subWord.bytes[2]];
    subWord.bytes[1] = s_h[subWord.bytes[1]];
    subWord.bytes[0] = s_h[subWord.bytes[0]];

    return subWord.word;
}

,错误就像

    C:/Users/pcw/Documents/Visual Studio 2012/Projects/MyCudaApp        /MyCudaApp/TEST AES.cu(157): error : expected a ";"
  1>C:/Users/pcw/Documents/Visual Studio 2012/Projects/MyCudaApp/MyCudaApp/TEST AES.cu(175): error : expected a ";"
  1>C:/Users/pcw/Documents/Visual Studio 2012/Projects/MyCudaApp/MyCudaApp/TEST AES.cu(179): error : expected a ";"
  1>C:/Users/pcw/Documents/Visual Studio 2012/Projects/MyCudaApp/MyCudaApp/TEST AES.cu(218): error : expected a ";"

1 个答案:

答案 0 :(得分:1)

您尝试编译的代码包含gcc specific variable attributes,Microsoft C ++编译器不支持这些代码。

要编译它,您需要将__attribute__替换为Visual Studio能够理解的内容。您可以看到对此问题的讨论here

相关问题