首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编译时间错误5

编译时间错误5
EN

Stack Overflow用户
提问于 2016-11-29 04:58:18
回答 1查看 27关注 0票数 0

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

代码语言:javascript
复制
// 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文件时,它返回给我错误:

代码语言:javascript
复制
 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 \
EN

回答 1

Stack Overflow用户

发布于 2016-11-29 06:17:35

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

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

这将指示编译器使用新的C++标准。默认情况下,g++针对没有标头的旧C++标准进行编译。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40853342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档