473,395 Members | 1,856 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,395 software developers and data experts.

Namespace Injection and std::size_t

I am trying to add the headers for a library I am using to a namespace
to avert issues with name clashes.

namespace Lib
{
#include <Lib/SomeFile.h>
};

I am finding though that statements to the following effect in that
code are then broken ...

using std::size_t;

The compiler complains that it doesn't know about size_t, I presume
that is because it only knows about Lib::std::size_t.

How can I get out of this?

Nov 16 '06 #1
2 1940
Maybe could help

namespace Lib
{
using namespace std;

#include <Lib/SomeFile.h>
}

Nov 16 '06 #2
earthwormgaz wrote:
I am trying to add the headers for a library I am using to a namespace
to avert issues with name clashes.

namespace Lib
{
#include <Lib/SomeFile.h>
};

I am finding though that statements to the following effect in that
code are then broken ...

using std::size_t;

The compiler complains that it doesn't know about size_t, I presume
that is because it only knows about Lib::std::size_t.
Most likely, SomeFile.h #includes a header from the standard library. If
you #include a standard library header inside a namespace the behavior
of the program is undefined, precisely because of this sort of problem.
But even if you dodge around the problems this causes for the standard
library, there's a good chance that the other library you're using won't
work right, because it wasn't compiled with its names inside your namespace.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Nov 16 '06 #3

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

Similar topics

5
by: Christopher | last post by:
can someone refresh my meory on what std::size_t is used for? I am wondering if my template container class should have it's capacity as a size_t or an int? , Christopher
3
by: JKop | last post by:
I'm writing a ".cpp" and ".hpp" combination. The ".hpp" just contains one sole function declaration. The ".cpp" makes use of the function "std::strlen" and the type "std::size_t".
20
by: Patrick Guio | last post by:
Dear all, I have some problem with insertion operator together with namespace. I have a header file foo.h containing declaration of classes, typedefs and insertion operators for the typedefs in...
6
by: Steve | last post by:
Hi, I have some code which compiles with Metrowerks CodeWarrior 9.6, Visual Studio 2005 (both targeted to Windows). Or, at least, it did until I started using size_t. CodeWarrior has size_t...
1
by: Marcin Kalicinski | last post by:
Is size_t guaranteed to be in the global namespace, or should I use std::size_t?
5
by: greg.ruthenbeck | last post by:
Hi, I'm using Boost::uBLAS::mapped_matrix for working with sparse matrices. At the moment, the maximum dimension of mapped_matrix is 65535x65535 since std::size_t compiles as unsigned int...
7
Axon
by: Axon | last post by:
Is there a way to force std::size_t to be compiled as __uint64 (before STL etc are compiled). Where is size_t defined?
27
by: mike3 | last post by:
Hi. I can't believe I may have to use an array here. I've got this bignum package I was making in C++ for a fractal generator, and tried an approach that was suggested to me here a while...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.