2016-11-28 3 views
0

암호 해독 코드에서 작업하고 있습니다. .size()을 사용하여 배열의 크기를 가져오고 싶으므로 <array> 라이브러리를 코드에 추가하고 싶습니다. 여기 코드는 다음과 같습니다컴파일 시간 오류 5

// Package: Crypto-PAn 1.0 
// File: sample.cpp 
// Last Update: April 17, 2002 
// Author: Jinliang Fan 

#include <stdlib.h> 
#include <stdio.h> 
#include "panonymizer.h" 
#include <array> 

int main(int argc, char * argv[]) { 
// Provide your own 256-bit key here 
unsigned char my_key[32] = 
{21,34,23,141,51,164,207,128,19,10,91,22,73,144,125,16, 
216,152,143,131,121,121,101,39,98,87,76,45,42,132,34,2}; 

FILE * f; 
unsigned int raw_addr, anonymized_addr; 

// Create an instance of PAnonymizer with the key 
PAnonymizer my_anonymizer(my_key); 

float packet_time; 
unsigned int packet_size, packet_addr1, packet_addr2, packet_addr3, packet_addr4; 

if (argc != 2) { 
    fprintf(stderr, "usage: sample raw-trace-file\n"); 
    exit(-1); 
} 

if ((f = fopen(argv[1],"r")) == NULL) { 
    fprintf(stderr,"Cannot open file %s\n", argv[1]); 
    exit(-2); 
} 

//readin and handle each line of the input file 
while (fscanf(f, "%f", &packet_time) != EOF) { 
fscanf(f, "%u", &packet_size); 
fscanf(f, "%u.%u.%u.%u", &packet_addr1, &packet_addr2, &packet_addr3, &packet_addr4); 

//convert the raw IP from a.b.c.d format into unsigned int format. 
raw_addr = (packet_addr1 << 24) + (packet_addr2 << 16) + (packet_addr3 << 8) + packet_addr4; 

//Anonymize the raw IP 
anonymized_addr = my_anonymizer.anonymize(raw_addr); 

//convert the anonymized IP from unsigned int format to a.b.c.d format 
packet_addr1 = anonymized_addr >> 24; 
packet_addr2 = (anonymized_addr << 8) >> 24; 
packet_addr3 = (anonymized_addr << 16) >> 24; 
packet_addr4 = (anonymized_addr << 24) >> 24; 

//output the sanitized trace 
printf("%6f\t%u\t%u.%u.%u.%u\n", packet_time, packet_size, packet_addr1, packet_addr2, packet_addr3, packet_addr4); 
} 

} 

나는 메이크업 파일을 실행하거나 오류와 함께 나에게 다시 반환 .cpp 파일을 컴파일 할 때 :

error: #error This file requires compiler and library support for the ISO C++ 2011 standard. 
       This support is currently experimental, and must be 
       enabled with the -std=c++11 or -std=gnu++11 compiler options. 
     #error This file requires compiler and library support for the \ 
+1

왜 #include 이 있습니까? – NathanOliver

+3

오류 메시지의 지침을 따르는 것은 어떻습니까? –

답변

0

추가 -std = C++ 11 컴파일러를 명령 행. 예를 들어 는 :

g++ -std=c++11 myFile.cpp

이 새로운 C++ 표준을 사용하도록 컴파일러에 지시합니다. 기본적으로 g ++는 헤더가없는 구형 C++ 표준을 위해 컴파일합니다.

+0

나는 그것을 시도했지만 여전히 동일했다. – momen