내 프로젝트에서 CPU가 지원하는 SIMD 명령어 세트를 결정해야합니다. 문제는 테스트 컴파일을 시도 할 때 컴파일러가 코드를 여러 번 파싱하는 것과 같이 여러 번 반복되는 일련의 오류가 발생한다는 것입니다. 지원되는 SIMD 명령어를 결정하는 이유는 Windows & Linux 용 GPGPU (특히 CUDA)에서 사용하기 위해 John the Ripper의 DES 비트 조각 구현을 적용하려고하기 때문입니다. 내 오류가 여기에 컴파일시 반복되는 구문 오류
// 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
37
내가 얻을 오류가있는 라인에서 발생하는 위치그래서, 여기에 (그 중 86있다 그러나 그들은 아래로/줄 번호 모든 방법 오류 같은 일련의 반복) :
첫 번째 나머지는 멀리 갈 수 있습니다 수정 -CPUInfo
이미 존재하는이 주장 -
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
이 파일을 #include 할 수는 없지만 제대로 컴파일하려면 함수 내에 포함시켜야합니다. 그 기능이 무엇인지는 알지 못합니다.이 헤더가 있으면 샘플 사용법을 찾으십시오. –
컴파일러는 일반적으로 첫 번째 오류가 발생한 후 계속 시도합니다. 코드에서 둘 이상의 문제를 찾을 수 있기 때문입니다. 문제는 C++이 구문 분석하기가 어렵다는 것입니다. 첫 번째 오류는 컴파일러가 나머지 코드를 잘못 해석하여 여러 가지 오류가 발생하기 때문에 혼란 스럽습니다. 첫 번째 문제를 해결하고 나머지가 사라지는지 확인하십시오 (또는 적어도 더 나은 진단 정보를 얻을 수 있습니다). –