编译时间错误5

时间:2016-11-28 20:58:18

标签: c++

我正在使用密码代码。我想将<array>库添加到我的代码中,因为我想使用.size()检索其上的数组大小。这是代码:

// 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 );
}

}

当我运行make文件或编译.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 个答案:

答案 0 :(得分:0)

将-std = c ++ 11添加到编译器命令行。 例如:

  

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

这指示编译器使用新的C ++标准。默认情况下,g ++编译旧的C ++标准,它没有标题。