About compiling errors, using <list> or <list.h>

Y

yatko

Hi all;

I am developing a multi-threaded program, and due to concurency there
is a producers-consumers problem between threads. Therefore, I have to
write a thread safe queueu, and I have written the following class.
But it gives compiling errors. Actually, I do not understand what the
problem is.

When I am compiling the following code with #include <list> header
file, it gives the following errors.

.../main.cpp:43: error: ISO C++ forbids declaration of 'list' with no
type
.../main.cpp:43: error: expected ';' before '<' token
.../main.cpp:45: error: expected nested-name-specifier before 'list'
.../main.cpp:45: error: expected ';' before '<' token
.../main.cpp:46: error: expected nested-name-specifier before 'list'
.../main.cpp:46: error: expected ';' before '<' token


But when I change <list> into <list.h>, it compiles without errors but
with following warning. I think that I should have to include <list>
header file, but it gives errors. I dont know what the mistake is.

Thanks for any help

yatko


Compiling&Linking messages
------------------------------------------------------------------------------------------------------------------------------------------------------------
**** Build of configuration Debug for project cidmTest ****

make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/local/boost_1_34_1 -O0 -g3 -Wall -c -fmessage-length=0 -MMD
-MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
In file included from /usr/lib/gcc/i486-slackware-linux/
4.1.2/../../../../include/c++/4.1.2/backward/list.h:59,
from ../main.cpp:3:
/usr/lib/gcc/i486-slackware-linux/4.1.2/../../../../include/c++/4.1.2/
backward/backward_warning.h:32:2: warning: #warning This file includes
at least one deprecated or antiquated header. Please consider using
one of the 32 headers found in section 17.4.1.2 of the C++ standard.
Examples include substituting the <X> header for the <X.h> header for C
++ includes, or <iostream> instead of the deprecated header
<iostream.h>. To disable this warning use -Wno-deprecated.
Finished building: ../main.cpp

Building target: cidmTest
Invoking: GCC C++ Linker
g++ -o"cidmTest" ./main.o -lboost_thread-gcc41-mt-1_34_1
Finished building target: cidmTest
------------------------------------------------------------------------------------------------------------------------------------------------------------

Definition of class
------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <list>
#include <iostream>

#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>


boost::mutex io_mutex;
const int BUFFER_SIZE = 1024;
const int ITERS = 100;

template <class DataType>
class ProducersNConsumers
{

public:

typedef boost::mutex::scoped_lock scoped_lock;

ProducersNConsumers();

~ProducersNConsumers();

DataType Pop(void);

void Push(DataType);

void Print(void);

private:

struct Node {
DataType data;
bool valid;

Node(DataType, bool);
};

int itemCount;

list<Node> buffer;

typename list<Node>::iterator popIterator;
typename list<Node>::iterator pushIterator;

boost::mutex enter;
boost::condition full;
boost::condition empty;

};
------------------------------------------------------------------------------------------------------------------------------------------------------------
 
V

Victor Bazarov

yatko said:
Hi all;

I am developing a multi-threaded program, and due to concurency there
is a producers-consumers problem between threads. Therefore, I have to
write a thread safe queueu, and I have written the following class.
But it gives compiling errors. Actually, I do not understand what the
problem is.

When I am compiling the following code with #include <list> header
file, it gives the following errors.

../main.cpp:43: error: ISO C++ forbids declaration of 'list' with no
type
[..]

The template 'list' lives in the namespace 'std'. Please read up
on using the standard types and objects.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top