-3

I have troubles to include deque in my C code. I thought that deque should be a standard library, but when I am trying to include it with #include <deque> the compiler's answer is: No such file or directory. I was searching for header in files given by

gcc -print-prog-name=cc1 -v

and there is really no deque to be found. Does it exist such library for C and how can I install it? I don't want to write my own implementation.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Zuz
  • 9
  • 2
  • 2
    You might want to consider using C++ rather than C, since deque is part of the standard C++ library. – Paul R Aug 19 '14 at 08:22
  • Where is you code? [Here](http://www.cplusplus.com/reference/deque/deque/deque/) you can find working example of `#include `, but it is only for c++. – Ilya Aug 19 '14 at 08:22
  • If you mean the C++ [`std::deque`](http://en.cppreference.com/w/cpp/container/deque) class, using the `` header file, then you're out of luck, because it's a ***C++*** class. If you're looking for a pure C library, you should turn to your favorite search engine. – Some programmer dude Aug 19 '14 at 08:22
  • 1
    Lots of examples for C around [**Queues**](http://www.cs.uah.edu/~rcoleman/Common/CodeVault/Code/Code130_Queue.html). As one example. – David C. Rankin Aug 19 '14 at 08:23
  • 1
    @DavidC.Rankin A [deque](http://en.wikipedia.org/wiki/Deque) is similar to a [queue](http://en.wikipedia.org/wiki/Queue_%28data_structure%29) but it's not quite the same. – Some programmer dude Aug 19 '14 at 08:25

2 Answers2

3

There is no header file for deque in C. Either you have to write your own implementation or you have to switch to C++ to get it from standard library.

Ravi
  • 59
  • 3
  • Some non-standard C libraries might offer some *deque* implementations (perhaps thru macros in header files). – Basile Starynkevitch Aug 19 '14 at 08:32
  • @BasileStarynkevitch: Even if there was a C implementation of deque, the header would most likely be `` and not `` — the suffix-less header names are distinctively for "standard C++". – Jonathan Leffler Dec 24 '17 at 02:10
1

Standard C does not know about deque-s. Some libraries (SGLIB or Glib from GTK, etc...) might provide them.

On Linux with GCC invoked as g++, standard header files for C++ are in /usr/include/c++/4.9 (for g++ version 4.9). Compile with g++ -Wall -g -H your C++ code if you want to know which header files are included.

C++ is not the same as C!

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547