|
In AgencyObject.cpp file, I included CStdSting.h. So I checked the AgnecyObject.i file and macros are coming like following
template<typename CT>
class _SS : public stlp_std::basic_string<CT>
{
typedef stlp_std::basic_string<CT> MYBASE;
typedef _SS<CT> MYTYPE;
typedef MYBASE::const_pointer PCMYSTR;
typedef MYBASE::pointer PMYSTR;
typedef MYBASE::iterator MYITER;
typedef MYBASE::const_iterator MYCITER;
typedef MYBASE::size_type MYSIZE;
typedef MYBASE::value_type MYVAL;
typedef MYBASE::allocator_type MYALLOC;
VS8 is giving the error for last 2
typedef MYBASE::value_type MYVAL;
typedef MYBASE::allocator_type MYALLOC;
Regards,
Vishal Soni
|
|
|
|
|
I'm guessing you're also getting error message something like this?
a.cpp(18) : warning C4346: 'stlp_std::basic_string<_CharT,_Traits,_Alloc>::value_type' : dependent name is not a type
prefix with 'typename' to indicate a type
a.cpp(20) : see reference to class template instantiation '_SS<CT>' being compiled
If so, it's a shame you didn't mention those before, 'cause they explain everything - VC++ used to be less standards compliant - it would presume that was the name of a type, where it shouldn't have done. The error message says what's needed - the declaration of allocator_type and value_type need to have typename added to the type being aliased, like this:
typedef typename MYBASE::value_type MYVAL;
typedef typename MYBASE::allocator_type MYALLOC;
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks Stuart. It is workiing now.
I did not cheked the warning message before you pointed me.I was ignoring all warnings.
I was using same CStdString.h file in VC6 from long time.
Thanks again. Now I will try to use both Stlport and Microsoft STL in same project.
Regards,
Vishal Soni
|
|
|
|
|
I am adding to this chain I find issue is related to this.
Even though I am able to compile and link the project project using STLPort library. My code crashes when it tries to access a std::vector. The vector has been initialized using STLport STL.
when I initialized the vector it used stlp_std
MYApp.exe!stlp_std::vector<external_Lib::customString,stlp_std::allocator<external_Lib::customString> >::_M_insert_overflow(external_Lib::customString* __pos=0x075cc4d0, const external_Lib::customString & __x={...}, const stlp_std::__false_type & __formal={...}, unsigned int __fill_len=1, bool __atend=true) Line 161 + 0x38 bytes C++
when the 3rd party library code (built with Visual studio STL) access the vector it uses the Visual studio stl (std::vector) and hence crashes.
MYApp.exe!std::vector<external_Lib::customString,std::allocator<external_Lib::customString > >::begin() Line 633 + 0x13 bytes C++
Is there any solution to fix this?
|
|
|
|
|
I am adding to this chain as I find my issue is related to this.
Even though I am able to compile and link the project project using STLPort library. My code crashes when it tries to access a std::vector. The vector has been initialized using STLport STL.
when I initialized the vector it used stlp_std
MYApp.exe!stlp_std::vector<external_Lib::customString,stlp_std::allocator<external_Lib::customString> >::_M_insert_overflow(external_Lib::customString* __pos=0x075cc4d0, const external_Lib::customString & __x={...}, const stlp_std::__false_type & __formal={...}, unsigned int __fill_len=1, bool __atend=true) Line 161 + 0x38 bytes C++
when the 3rd party library code (built with Visual studio STL) access the vector it uses the Visual studio stl (std::vector) and hence crashes.
MYApp.exe!std::vector<external_Lib::customString,std::allocator<external_Lib::customString > >::begin() Line 633 + 0x13 bytes C++
Is there any solution to fix this?
|
|
|
|
|
Are you STL port header files?
This thing happens when there is something mix up of STL port library and microsoft library.
Regards,
Vishal
|
|
|
|
|
Actually my application uses STLPort libraries. So I am using the headers from STLPort 5.1 too. The 3rd party library (.lib) which I am trying to use in my application is using Visual studio STL. let me try to explain the problem.
This 3rd Party library has class OutputOptions which has a private member std::vector<string> _names. This class also has a public inline function addNames(string &name) {_names. pushback (name)}. In my application I have a OutputOptions object and I add names to this OutputOptions object using the inline function.[I can add the names, no issues in adding]. see the call stack at this point it uses stlp_std (stlport)
MYApp.exe!stlp_std::vector<3rdPartyLib::String,stlp_std::allocator<3rdPartyLib::String > >::push_back(const 3rdPartyLib::String & __x={...}) Line 368 C++
MYApp.exe!OutputOptions::addNames(const 3rdPartyLib::String & value={...})
But When the 3rd party library tries to access the _names vector using constant iterator the vector is corrupted and the application crashes. See the call stack when it tries to access the _names vector. it uses std::vector. I think that's the problem.
MYApp.exe!std::_Iterator_base::_Adopt(const std::_Container_base * _Parent=0x0190a3f4) Line 164 C++
MYApp.exe!std::_Vector_const_iterator<3rdPartyLib::String,std::allocator<3rdPartyLib::String> >::_Vector_const_iterator<3rdPartyLib::String,std::allocator<3rdPartyLib::String> >(3rdPartyLib::String * _Ptr=0x075c1bb8, const std::_Container_base * _Pvector=0x0190a3f4) Line 73 C++
MYApp.exe!std::vector<3rdPartyLib::String,std::allocator<3rdPartyLib::String> >::begin() Line 633 + 0x13 bytes C++
I don't know how to fix this.
-Avijit
|
|
|
|
|
Hi Vishal,
I am also running into same errors, can you please let me know incase you got the linking error solution.
Thanks,
Sandeep
|
|
|
|
|
I have been at this all night and I am still no closer to a solution.
The problem is that utf16_codecvt methods never get called and, therefore, the result is wrong. I have search the net, but all I can find is examples of what is supposed to work. Unfortunately none of them has worked. I have also seen other posters, on the net, with the same problem, but no one gave them and answer to it.
I have tested to make sure that it has the facet (utf16_codecvt) and it does. So I see no reason why its virtual methods are never called. Instead it keeps calling the codecvt<wchar_t,char, mbstate> methods.
Any ideas?
class utf16_codecvt : public std::codecvt<char16_t, char16_t, std::mbstate_t>
{
...
};
void MyTestFunc()
{
...
std::wifstream myFile;
std::locale myLoc = std::locale(myFile.getloc(), new utf16_codecvt);
myFile.imbue(myLoc);
myFile.open(pFileName, std::ios::in | std::ios::binary);
...
myFile.read(bom_buffer, 1);
...
}
The following link gives an example of the types of things I am trying to do.
April 01, 1999 - Unicode Files - P.J. Plauger http://www.ddj.com/cpp/184403638?pgno=1[^]
Signed, Very <blanking> tired.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
From what I can tell, the C++ stream system presumes that files are sequences of bytes, not characters - even when you use wide streams - the 'wide' part of wide stream (AFAICT) indicates how the stream object interacts with C++, not the underlying file or whatever. Thus, your codecvt facet has to take in characters.
By changing the declaration of your codecvt facet to that shown below, I was able to get breakpoints in the replacement facet being set.
class utf16_codecvt : public std::codecvt<char16_t, char, std::mbstate_t>
{
typedef std::codecvt<char16_t, char, std::mbstate_t> Base;
typedef char16_t ElemT;
typedef char ByteT;
virtual result __CLR_OR_THIS_CALL do_in(std::mbstate_t& s,
const ByteT *_First1, const ByteT *_Last1, const ByteT *& _Mid1,
ElemT*_First2, ElemT* _Last2, ElemT *& _Mid2) const
{
return Base::do_in(s, _First1, _Last1, _Mid1, _First2, _Last2, _Mid2);
}
virtual result __CLR_OR_THIS_CALL do_out(std::mbstate_t& s,
const ElemT*_First1, const ElemT*_Last1, const ElemT*& _Mid1,
ByteT*_First2, ByteT*_Last2, ByteT*& _Mid2) const
{
return Base::do_out(s, _First1, _Last1, _Mid1, _First2, _Last2, _Mid2);
}
virtual result __CLR_OR_THIS_CALL do_unshift(std::mbstate_t& s,
ByteT*_First2, ByteT*_Last2, ByteT*&_Mid2) const
{
return Base::do_unshift(s, _First2, _Last2, _Mid2);
}
virtual int __CLR_OR_THIS_CALL do_length(const std::mbstate_t& s, const ByteT*_First1,
const ByteT*_Last1, size_t _Count) const
{
return Base::do_length(s, _First1, _Last1, _Count);
}
};
So, your replacement facet will have to know it needs two bytes read for every character (and vice versa, obviously). The best reference for that sort of information is probably Standard C++ IOStreams and Locales by Angelika Langer and Klaus Kreft[^] - but even then, locales and facets are heavy going in C++
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks, Stuart
That worked great; I expected the problem was something like that. Something else I discovered was that the second template parameter has to be ‘char’ or it will not work. That is ‘unsigned char’ will not even work as the second parameter.
I need to dig up a copy of the standard to see if this is compliant and makes since, because having template parameters that can only be of a single integral type is illogical.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: Something else I discovered was that the second template parameter has to be ‘char’ or it will not work. That is ‘unsigned char’ will not even work as the second parameter.
I need to dig up a copy of the standard to see if this is compliant and makes since, because having template parameters that can only be of a single integral type is illogical.
I think there are two pertinent ideas here - firstly, files are streams of bytes (that's the basic concept underlying file streams in C++), which is why they always convert to/from bytes. Secondly, codecvt facets can be used on their own, without streams.
So, say you'd read in a file converting from a byte stream to (say) UCS-2. Then you want to write the UTF-32 equivalent to a file. You could use a codecvt facet that could convert from UCS-2 to UTF-32. The example code in the codecvt::in documentation on MSDN[^] shows this sort of scenario.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I am looking for a possibility to have a two way associative array. What I mean is that I would like to have an array say
My2WayArray<int, string=""> _twoWayArray;
and I can do the following
_twoWayArray["user1"] = 123;
_twoWayArray["user2"] = 456;
and
_twoWayArray[123] = "user1";
_twoWayArray[456] = "user2";
this way I will be able to lookup a user if the integer (used as user id) is specified and integer id if user name is provided.
I don't want to use it anywhere, it is just out of curiosity.
While I am posting this question I am trying to figure it out at my end.
Thanks and Regards
|
|
|
|
|
|
Bah - you beat me to it by a matter of seconds
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Like this[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
It's a pity they don't have something like this in the .NET collection classes. And it doesn't seem to exist in the third party libraries either.
Kevin
|
|
|
|
|
Probably be quite difficult to port the approach used in Boost - one of the first comments I saw in the bimap headers was:
Once you're using the words 'mpl' (== C++ template metaprogramming library) and 'magic' together, there's little to no hope of translating the code directly to another language. I suspect some form of code generator would be the best bet (I seem to remember a container generator being written by someone before C# got generics - that would be similar).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you Andy and Stuart for the reply.
I was looking for boost bi-map type functionality.
Regards
|
|
|
|
|
Hi,
I need to implement the RPC in windows XP based system and I created an IDL file which contains the RPC calls and i created stub files. While compiling with server and client application it shows "You need a Windows NT Version 4.0 or Later to run this stub".But i am using Microsoft Visual C++ 6.0. Can anyone help to solve this problem?
Thanks,
S.Suthakar
|
|
|
|
|
You probably need to set WINVER[^] to reflect you're using Windows XP, rather than Windows 98, which was the current version of Windows when VC6 came out.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
What Stuart said and depending on what you are using you might need to have an updated Platform SDK[^] from the original VC6
|
|
|
|
|
I am using original version. The auto generated code only shows the error(defined in #).if i remove that then it is compiled.
|
|
|
|
|
suthakar56 wrote: I am using original version. The auto generated code only shows the error(defined in #).if i remove that then it is compiled.
I have no new information. Follow the advice previously given by myself and Stuart.
|
|
|
|
|
Good point - I forgot that one. So long since I used VC6....since I moved to VS2003, I've always used a Visual Studio newer than my standard target (Windows 2000 - we've not managed to make the giant leap to XP or Vista at the company I work for).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|