0

私のプロジェクトでは、CPU がサポートする SIMD 命令セットを特定する必要があります。問題は、テスト コンパイルを実行しようとすると、コンパイラがコードを複数回解析しているように、一連のエラーが数回繰り返されることです。サポートされている SIMD 命令を決定する理由は、Windows と Linux の両方の GPGPU (特に CUDA) で使用するために John the Ripper の DES ビットスライス実装を適応させようとしているためです。

だから、これが私のエラーが37行目で発生する場所です

// File Name: Arch.h
// Purpose: Determine CPU architecture (x86 or x86-64) and to determine instruction set supported by
//          the CPU (MMX, SSE2 or neither)
// 
// Authors: Daniel Beard and Michael Campbell

//If CPU is x86-64 then use x86-64 include
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64)
#include "x86-64.h"
#endif

//Determine if CPU architecture is 32-bit, then determine which compiler is being used, finally determine if GCC (GNUC) or MS Visual C++ compiler is being used
#if defined(i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86)
    #if defined(__GNUC__) 
    #define cpuid(func,ax,bx,cx,dx)\
        __asm__ __volatile__ ("cpuid":\
        "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (func));
    int a,b,c,d;
    cpuid(0x1,a,b,c,d);
    if ((d & 0x17)== 1)
    {
        #include "x86-mmx.h"
    }
    else if (d & 0x1A) == 1)
    {
        #include "x86-sse.h"
    }
    else if((d & 0x17) != 1 || (d & 0x1A) != 1)
    {
        #include "x86-any.h"
    }
    #endif

    #if defined(_MSC_VER)
        #include<intrin.h>
        int CPUInfo[4] = {0};
        __cpuid( CPUInfo, 1 );
        if( (CPUInfo[3] & 0x1A) == 1 )
        {
            #include "x86-sse.h"
        }
        else if( (CPUInfo[3] & 0x17) == 1 )
        {
            #include "x86-mmx.h"
        }
        else if( (CPUInfo[3] & 0x17) != 1 || (CPUInfo[3] & 0x1A) != 1 )
        {
            #include "x86-any.h"
        }
    #endif
#endif

ここに私が得るエラーがあります(86個ありますが、同じ一連のエラー/行番号がずっと繰り返されます):

Error   1   error C2059: syntax error : ','                    line 37  
Error   2   error C2143: syntax error : missing ')' before 'constant'      line 37  
Error   3   error C2143: syntax error : missing '{' before 'constant'      line 37  
Error   4   error C2059: syntax error : '<Unknown>'                line 37  
Error   5   error C2059: syntax error : ')'                    line 37  
Error   6   error C2059: syntax error : 'if'                   line 38  
Error   7   error C2059: syntax error : 'else'                 line 42  
Error   8   error C2059: syntax error : 'else'                 line 46  
Error   9   error C2374: 'CPUInfo' : redefinition; multiple initialization     line 36
4

1 に答える 1

1

最初のエラーは 36 行目です - すでに存在すると主張してCPUInfoます - 最初にそれを修正すると、残りはなくなる可能性があります。

Visual Studio のオプションで、[プロジェクトとソリューション]、[全般] に移動し、[常にエラー リストを表示する...] のチェックを外します。

出力ウィンドウが表示されます。F8 を使用して、通常は気にする必要がある最初の警告/エラーに移動できます。

于 2011-03-15T19:51:47.043 に答える