What does this compiler warning mean?

Every time I compile my program i get this warning :

1
2
3
4
5
6
7

In file included from /usr/include/c++/4.8.2/thread:35:0,
                 from proj2.cpp:15:
/usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: 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 \
  ^


Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <thread>
#include <vector>
#include <pthread.h>

using namespace std;

// vector used to hold fibonacci values. Shared by all.
vector<int> fibo_values;
// Thread
void * calculate_fibonacci(void * parameter);
// Prints Fibonacci values
void print_fibonacci();


int main (int argc, char ** argv)
{
    pthread_t thread1;
    pthread_attr_t attr;

    if (argc != 2) {
	cerr << "Usage: a.out <integer value > \n";
	return -1;
    }

    if (atoi (argv[1]) < 0) {
	cerr << argv[1] << " must be >= 0\n";
	return -1;
    }
 
    cerr << "Attributes Error\n";
    // intialize default Thread attributes
    pthread_attr_init(&attr);
    cerr << "Thread creation error\n";
    // Thread created
    pthread_create ( &thread1, &attr, calculate_fibonacci, argv[1]);
    cerr << "Thread join error\n";
    // Wait for Thread to exit
    pthread_join ( thread1, NULL);

    print_fibonacci();

}

// Thread used to calculate fibonacci values
void * calculate_fibonacci (void * parameter)
{
    int param = atoi((const char*)parameter); 

    if (param == 0) 
	fibo_values.push_back(0);
    else if (param == 1) {
	fibo_values.push_back(0);
        fibo_values.push_back(1);
    }
    else if (param >= 2) { 
	fibo_values.push_back(0);
        fibo_values.push_back(1);
	for (int i=0; i < param; i++){
	    int fib = fibo_values[i-1]+fibo_values[i-2];
							
	    fibo_values.push_back (fib);
	}
    }
}

// fibonacci values are printed
void print_fibonacci ()
{
    for (int i=0; i < fibo_values.size(); i++)
	cout << "Fibs [ " << i << " ] = " << fibo_values[i] << endl;
}




I dont think I'm missing any libraries, if so which ones?
Have you tried compiling this code with a different compiler?
Like the error message says, you need to compile with the -std=c++11 or -std=gnu++11 compiler options. Have you tried doing that?
I think your compiler does not fully support C++11, try downloading the latest version of you IDE, C::B 12.11 or at least VS2012
thanks everyone.

Unfortunately I cannot update the compiler because i am using a remote desktop connection to a server that i cannot alter.

i tried using the -w command when compiling but it did nothing.
Did you do what @MikeyBoy suggested? For you makefile (or whatever you are using to compile your code), add the -std=c++11 option to your compiler flags. Here would be a simple command line example:

$ g++ proj2.cpp -o proj2 -std=c++11 -pthread   #add other link libraries, etc...
Last edited on
I realized I was using C libraries when my program is in C++, so i removed the .h off some of them.

Thanks NT3, i tried that and it compiled.
Topic archived. No new replies allowed.