Is there a library that I need to include to use STL with a MC++ project?
Thanks. Jon. 5 2507
Short anwser - yes
Longer answer - depends on which STL constructs you are using
Here are some examples
#include <vector>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <string>
"jlea" <jo*@leapsoft.com> wrote in message news:<eC**************@TK2MSFTNGP12.phx.gbl>... Is there a library that I need to include to use STL with a MC++ project? Thanks. Jon.
I tried that, it compiles but at link, it can't find a bunch of stuff. It's
like I need to include a .lib file in the link or something in stdafx.h.
Jon.
"Mark Mullin" <mu****@vibrant3d.com> wrote in message
news:32**************************@posting.google.c om... Short anwser - yes
Longer answer - depends on which STL constructs you are using
Here are some examples
#include <vector> #include <stack> #include <map> #include <string> #include <algorithm> #include <set> #include <string>
"jlea" <jo*@leapsoft.com> wrote in message
news:<eC**************@TK2MSFTNGP12.phx.gbl>... Is there a library that I need to include to use STL with a MC++
project? Thanks. Jon.
I can't comment on the LeapSoft reference, but I can make some general
comments and offer a workable strategy.
1) STL is a very heavy user of very complicated templates. When it
was first distributed it had a reputation for busting compilers right
and left, even though it was completely legal C++ code.
2) Use of templates requires that the compiler instantiate
specializations of them based on how you are using them. Effectively,
using list<MyObject> requires an internal class be constructed that
represents the template code where the template variables have been
replaced with MyObject.
3) In the early days of templates, use of them could lead to massive
'code bloat', i.e. the template was instantiated and reinstantiated
multiple times as it was encountered/used. You could get a template
version of "Hello World" weighing in at umpteen megs. Further work by
both standards committees and compiler vendors has attempted to
address this, but at its heart, the problem is just plain nasty.
4) MSFT does many strange and wonderful things with new and delete
operators and mem<x> operations in their headers and libraries. I'm
not pointing fingers, they have many more constituencies to serve than
just myself, but I've been bitten by this often.
5) Precompiled headers are an attempt to ensure that developers do not
visibly age while waiting for the compiler to convert their source to
object. Precompiled headers, templates, and template optimization can
often step on each others feet.
So heres the solution we use.
First, don't let visual studio decide how it's going to do precompiled
headers. Its not that bright.
Create a .cpp file that will specifically be the one to create the
precompiled headers. It should read in all the windows cruft, any
files you use to configure the compiler (usually pragmas), and the
relevant stl libraries. Here's a slice from the file used to generate
precompiled headers for our Node library. Note it doesn't have
windows includes, you probably will have em, after compiler config and
any real gut level stuff like new.h
#include "compilerconfig.h" (this is our file used to configure the
compiler pragmas and fpu)
#include <new.h> (you may not need this)
#include <math.h> (we're math geeks)
#include <float.h> (really major math geeks)
#include <iostream> (probably)
#include <fstream> (probably)
#include "template.h" (heres where you bring in stl)
The template.h file should include the headers you want, ours (for
node) looks like
#pragma once
#include <vector>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <string>
/*! \ingroup SYSCORE */
class less_string_Ptr {
public:
bool operator()(const std::string* a,const std::string* b) const
{
return *a < *b;
}
bool operator()(std::string* a,std::string* b) const
{
return *a < *b;
}
};
Now, pop open the properties of your precompiled.cpp, and set it to
'create precompiled headers' under the precompiled headers tab. For
all other .cpp files, set the option to 'use precompiled headers'.
Set the .h file in both to be the last .h file in precompiled.cpp that
you want to be in this.
If you haven't mucked about with precompiled headers before, crack
open the doco and read up a bit on em. It's important that all files
using precompiled headers have a common .h file sequence that serves
to match everything up, the doco will expain this.
When that's all done, you should be ready to rock.
MMM
Thanks for the detail response and I'll give your suggestions a try. The
reason why I was confused is that with v6.0 of Visual Studio, we just
included <list> in a header file of our choice and presto, we were able to
declare member variables of type list within that header file. It appears it
isn't that simple in .NET? Jon.
"Mark Mullin" <mu****@vibrant3d.com> wrote in message
news:32**************************@posting.google.c om... I can't comment on the LeapSoft reference, but I can make some general comments and offer a workable strategy.
1) STL is a very heavy user of very complicated templates. When it was first distributed it had a reputation for busting compilers right and left, even though it was completely legal C++ code.
2) Use of templates requires that the compiler instantiate specializations of them based on how you are using them. Effectively, using list<MyObject> requires an internal class be constructed that represents the template code where the template variables have been replaced with MyObject.
3) In the early days of templates, use of them could lead to massive 'code bloat', i.e. the template was instantiated and reinstantiated multiple times as it was encountered/used. You could get a template version of "Hello World" weighing in at umpteen megs. Further work by both standards committees and compiler vendors has attempted to address this, but at its heart, the problem is just plain nasty.
4) MSFT does many strange and wonderful things with new and delete operators and mem<x> operations in their headers and libraries. I'm not pointing fingers, they have many more constituencies to serve than just myself, but I've been bitten by this often.
5) Precompiled headers are an attempt to ensure that developers do not visibly age while waiting for the compiler to convert their source to object. Precompiled headers, templates, and template optimization can often step on each others feet.
So heres the solution we use.
First, don't let visual studio decide how it's going to do precompiled headers. Its not that bright.
Create a .cpp file that will specifically be the one to create the precompiled headers. It should read in all the windows cruft, any files you use to configure the compiler (usually pragmas), and the relevant stl libraries. Here's a slice from the file used to generate precompiled headers for our Node library. Note it doesn't have windows includes, you probably will have em, after compiler config and any real gut level stuff like new.h
#include "compilerconfig.h" (this is our file used to configure the compiler pragmas and fpu) #include <new.h> (you may not need this) #include <math.h> (we're math geeks) #include <float.h> (really major math geeks) #include <iostream> (probably) #include <fstream> (probably) #include "template.h" (heres where you bring in stl)
The template.h file should include the headers you want, ours (for node) looks like #pragma once #include <vector> #include <stack> #include <map> #include <string> #include <algorithm> #include <set> #include <string> /*! \ingroup SYSCORE */ class less_string_Ptr { public: bool operator()(const std::string* a,const std::string* b) const { return *a < *b; } bool operator()(std::string* a,std::string* b) const { return *a < *b; } };
Now, pop open the properties of your precompiled.cpp, and set it to 'create precompiled headers' under the precompiled headers tab. For all other .cpp files, set the option to 'use precompiled headers'. Set the .h file in both to be the last .h file in precompiled.cpp that you want to be in this.
If you haven't mucked about with precompiled headers before, crack open the doco and read up a bit on em. It's important that all files using precompiled headers have a common .h file sequence that serves to match everything up, the doco will expain this.
When that's all done, you should be ready to rock.
MMM
I'll investigate the precompiled header scenario and let you know what I
find out. Thanks. Jon.
"Mark Mullin" <mu****@vibrant3d.com> wrote in message
news:32**************************@posting.google.c om... Actually, this behavior evolved for us in V5 or earlier, I think - whenever it was that stl appeared in VS, and we weren't manually bringing it in anymore.
Given this, I become even more certain you're getting munched by precompiled headers vs msft redefs
"jlea" <jo*@leapsoft.com> wrote in message
news:<O2**************@TK2MSFTNGP10.phx.gbl>... Thanks for the detail response and I'll give your suggestions a try. The reason why I was confused is that with v6.0 of Visual Studio, we just included <list> in a header file of our choice and presto, we were able
to declare member variables of type list within that header file. It
appears it isn't that simple in .NET? Jon.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Enos Meroka |
last post by:
Hallo,
I am a student doing my project in the university.. I have been trying
to compile the program using HP -UX aCC compiler, however I keep on
getting the following errors.
...
|
by: Mike L |
last post by:
Should the command call "using" be before or after my namespace?
**AFTER**
namespace DataGridBrowser
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using...
|
by: xzzy |
last post by:
I was wondering why we have to have
using System.Data
using System.Configuration
using etc....
why are they not all lumped into one 'using'?
In other words, is there a best way to use...
|
by: pmud |
last post by:
Hi,
I need to use an Excel Sheet in ASP.NET application so that the users can
enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever
the USER ENETRS needs to go to the...
|
by: acb |
last post by:
Hi,
I wrote a DLL Component (using Visual Studio 2005) and managed to
include it into a C# Console application.
I am now trying to include this component into a Web project. I copy
the DLL...
|
by: Metal2You |
last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that
accesses a Sybase database back end. We're using Sybase SQL Anywhere
9.0.2.3228. I have installed and registered the Sybase...
|
by: mg |
last post by:
I'm migrating from VB6 and have a question about using 'Using' and the
best way to use it.
Here is a example of a small bit of code:
dbConx("open")
Using CN
Dim CMD As New OleDbCommand(sSQL,...
|
by: Eugene Anthony |
last post by:
The problem with my coding is that despite removing the records stored
in the array list, the rptPages repeater
control is still visible. The rptPages repeater control displayes the
navigation...
|
by: JDeats |
last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting
and decrypting a file.
http://support.microsoft.com/kb/307010
In .NET 2.0 this approach is not fully supported (a .NET 2.0...
|
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= |
last post by:
Greetings! I was researching AJAX to provide a solution to displaying status
messages while a long process executed. I found several examples online and
was able to use their code to get a quick...
|
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...
|
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,...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |