473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

STL containers header guards.

Hello.

Do you know if there is any standard STL header guard for
vectors, lists, maps e.t.c?

I would like to write code like that

#ifndef STL_VECTOR_
#error "please include stl vector"
#endif
std::vector<double> foo;

I am searching an elegant way to prevent a flood of
compilation errors.

Many thanks.

Tuko
--
tuko the mexican. The ugly fellow.

Nobody cares how it works as long as it works.
(from the Matrix reloaded.)

Jul 22 '05 #1
2 1332

"tuko" <tu**@away.com> wrote in message news:ce**********@nic.grnet.gr...
Hello.

Do you know if there is any standard STL header guard for
vectors, lists, maps e.t.c?
No

I would like to write code like that

#ifndef STL_VECTOR_
#error "please include stl vector"
#endif
std::vector<double> foo;

I am searching an elegant way to prevent a flood of
compilation errors.


Why not the obvious way?

#include <vector>
std::vector<double> foo;

Every header file should include the header files needed for it to compile.

john
Jul 22 '05 #2
tuko wrote:
Hello.

Do you know if there is any standard STL header guard for
vectors, lists, maps e.t.c?

I would like to write code like that

#ifndef STL_VECTOR_
#error "please include stl vector"
#endif
std::vector<double> foo;

I am searching an elegant way to prevent a flood of
compilation errors.

Many thanks.

Tuko


If you were going to write an #ifndef line like the one shown above, then
you might just as well include the correct header in the first place.

If you really want to avoid a flood of errors, then you could always include
a file called 'library_headers.h' which itself includes all of the STL
headers that you use.

I doubt whether this is generally considered good style. Some of my code
that was originally written for C++ Builder does it, because its necessary
in order to get pre-compiled headers to work.

--
Chris Gordon-Smith
London
Homepage: http://graffiti.virgin.net/c.gordon-smith/
Email Address: Please see my Home Page
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: pristo | last post by:
hi to all, why when i use the command #define test 10 #define X test; #if (test == X) .... ......
14
by: Pedro Graca | last post by:
Imagine I have a structure with a size_t member: /* foo.h */ struct foo { char const *bar; size_t barlen; }; void make_foo(struct foo *p);
6
by: gamehack | last post by:
Hi all, Let me describe the problem. I've a header file util.h which contains the following: #ifndef UTIL_H_ #define UTIL_H_ const char DEF_TITLE = "My Title"; int num_chars(int num);
3
by: fc2004 | last post by:
Hi, Is there any tools that could report where cyclic header dependency happens? this would be useful when working with a large project where tens or hundreds of headers files may form complex...
12
by: Ben | last post by:
I'm kind of new to creating templates. I've made some small class and function templates in the past and I have used quite of bit of the STL, but I am having problems tyring to create templates. ...
3
by: linq936 | last post by:
Hi, I have a C++ header file like this, #include "MyClass1.h" class MyClass2{ private: MyClass1* c1; };
4
by: Christoph Scholtes | last post by:
Hi, I have some questions about header files: Say I have a file functions.c which contains a couple of functions. I have declared some structs in this file too. The structs are defined in...
36
by: zouyongbin | last post by:
Stanley B Lippman in his "C++ Primer" that a definition like this should not appear in a header file: int ix; The inclusion of any of these definitions in two or more files of the same...
14
by: Jess | last post by:
Hello, I was told that if I have a template class or template function, then the definitions must be put into the header file where I put the declarations. On the other hand, it is generally...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.