Using STL port in VS2008 - c++

I am working on porting our C++ code from eVC 4.0 to Visual Studio 2008. Our target is Windows Mobile 6.1 and we are using the Windows Mobile 6.0 SDK for our app.
Our code used stl port when compiled in eVC 4 and we would like to continue to use stl port if at all possible.
Does anyone know what steps are necessary to incorporate STL port (5.2.1) in our application. We have set the include directories in the solution (as we did for the eVC 4.0 project), but we are seeing the errors (below) any time we try to use list push_back or vector insert commands with our own classes (below is the error with our class "TriangleBufferElement"). These commands do seem to work with native types like int, double, etc.
We have ensured all classes have the proper contructors, copy constructors, assignment operators, and comparison operators and all appear to be correct.
Any ideas?
C:\Program Files\Windows CE Tools\stlport\stl/_construct.h(119) : error C2665: 'operator new' : none of the 2 overloads could convert all the argument types
1> C:\Program Files\Windows Mobile 6 SDK\PocketPC\include\../../../Windows Mobile 6 SDK\PocketPC\Include\Armv4i/new(61): could be 'void *operator new(unsigned int,const std::nothrow_t &) throw()'
1> while trying to match the argument list '(unsigned int, TriangleBufferElement *)'
1> C:\Program Files\Windows CE Tools\stlport\stl/_construct.h(134) : see reference to function template instantiation 'void stlp_std::_Copy_Construct_aux<_Tp>(_Tp *,const _Tp &,const stlp_std::__false_type &)' being compiled
1> with
1> [
1> _Tp=TriangleBufferElement
1> ]
1> C:\Program Files\Windows CE Tools\stlport\stl/_vector.h(381) : see reference to function template instantiation 'void stlp_std::_Copy_Construct<_Tp>(_Tp *,const _Tp &)' being compiled
1> with
1> [
1> _Tp=TriangleBufferElement
1> ]
1> C:\Program Files\Windows CE Tools\stlport\stl/_vector.h(376) : while compiling class template member function 'void stlp_std::vector<_Tp>::push_back(const _Tp &)'
1> with
1> [
1> _Tp=TriangleBufferElement
1> ]
1> c:\srcdevbranch\pointlib\dtmconverter\dtm\dtmreader\.\trianglebuffer.h(47) : see reference to class template instantiation 'stlp_std::vector<_Tp>' being compiled
1> with
1> [
1> _Tp=TriangleBufferElement
1> ]

Some links you probably should see (if not seen already):
STLPort Notes:
You may experience problems with default SGI node allocator. I had no such problems, though. Default node allocator is quite fast, so I wouldn't recommend disabling it without serious reason. However, if it causes problems, define _STLP_USE_MALLOC or _STLP_USE_NEWALLOC to get bare malloc()-based or new()-based default allocator.
Though this post says it has not yet been ported to VS2008.

Have you reconfigured STLPort for the new compiler environment? Visual Studio 2008 is quite different from the old eVC++ compiler.
Try:
configure evc9

In my case, this was due to __PLACEMENT_NEW_INLINE defined

Related

emplace_back different definitions

I'm using emplace_back function in a cpp project in visual studio and it works correctly. Visual studio shows following definition for it:
void std::vector<std::string>::emplace_back<CHAR(&)[1]>(CHAR(&_Val)[1])
Then, I'm going to move my cpp project files to a MFC project and use them in a dialog based app. When I moved codes to MFC project, emplace_back definition has changed to:
void std::vector<std::string>::emplace_back<WCHAR(&)[1]>(WCHAR(&_Val)[1])
And it leads to C2664 Error in xmemory0 after build:
Error C2664
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(const std::basic_string<char, std::char_traits<char>, std::allocator<char>> &)':
cannot convert argument 1 from 'WCHAR [1]' to 'std::initializer_list<_Elem>'
And in output it says:
note: see reference to function template instantiation 'void std::vector<std::string,std::allocator<_Ty>>::emplace_back<WCHAR(&)[1]>(WCHAR (&)[1])' being compiled
1> with
1> [
1> _Ty=std::string
1> ]
How can I deal with such problems? Is there any option in properties of Visual Studio Project to correct?
Thanks

Build error while using Armadillo on Windows platform

I had installed armadillo library on window visual studio 2013. When i attempted to build the solution. The following build error occurred. Any help will be appreciated.
1>------ Build started: Project: ConsoleApplication1, Configuration: Debug x64 ------
1> Source.cpp
1>c:\users\haixun\desktop\test_programs\testingapplication\armadillo-5.100.2\include\armadillo_bits/diskio_meat.hpp(787): error C4146: unary minus operator applied to unsigned type, result still unsigned
1> c:\users\haixun\desktop\test_programs\testingapplication\armadillo-5.100.2\include\armadillo_bits/diskio_meat.hpp(1626) : see reference to function template instantiation 'bool arma::diskio::convert_naninf<eT>(eT &,const std::string &)' being compiled
1> with
1> [
1> eT=arma::u32
1> ]
1> c:\users\haixun\desktop\test_programs\testingapplication\armadillo-5.100.2\include\armadillo_bits/diskio_meat.hpp(1652) : see reference to function template instantiation 'bool arma::diskio::load_arma_ascii<arma::u32>(arma::Mat<arma::u32> &,std::istream &,std::string &)' being compiled
1> c:\users\haixun\desktop\test_programs\testingapplication\armadillo-5.100.2\include\armadillo_bits/diskio_meat.hpp(1571) : see reference to function template instantiation 'bool arma::diskio::load_arma_ascii<double>(arma::Mat<double> &,std::istream &,std::string &)' being compiled
1> c:\users\haixun\desktop\test_programs\testingapplication\armadillo-5.100.2\include\armadillo_bits/Mat_meat.hpp(6553) : see reference to function template instantiation 'bool arma::diskio::load_arma_ascii<double>(arma::Mat<double> &,const std::string &,std::string &)' being compiled
1> c:\users\haixun\desktop\test_programs\testingapplication\armadillo-5.100.2\include\armadillo_bits/Mat_meat.hpp(6536) : while compiling class template member function 'bool arma::Mat<double>::load(const std::string,const arma::file_type,const bool)'
1> Source.cpp(50) : see reference to function template instantiation 'bool arma::Mat<double>::load(const std::string,const arma::file_type,const bool)' being compiled
1> c:\users\haixun\desktop\test_programs\testingapplication\armadillo-5.100.2\include\armadillo_bits/typedef_mat_fixed.hpp(41) : see reference to class template instantiation 'arma::Mat<double>' being compiled
1>c:\users\haixun\desktop\test_programs\testingapplication\armadillo-5.100.2\include\armadillo_bits/diskio_meat.hpp(794): error C4146: unary minus operator applied to unsigned type, result still unsigned
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Sorry that someone downvoted your question; it seems reasonable to me.
These are warnings, which in this particular case are harmless. You must have the option turned on to treat warnings as errors. Your options seem to be:
Turn off the option to treat warnings as errors.
Turn off that particular warning (project wide).
Turn off that particular warning whenever you #include <armadillo>.
Option 3 is probably best, especially if the warnings as errors option is company policy. Make sure to push and pop the warning options; see this MSDN page on warning pragmas. You could put the whole lot (pragmas and include) into a little header file, which is probably a good idea anyway since Visual Studio won't autocomplete #include <armadillo> (since it doesn't have a file extension).

Traverse template error and/or static assert 'pathway' in Visual C++

In Visual C++, when a static assert is fired or there is a template error, doubly clicking on the error itself will take you to the actual template code and not the actual erroneous code that is trying to call it or instantiate it.
To see the code that instantiated it, you have to go to the output window and essentially trace the error by double clicking on the lines that contain a source file with the wordings see reference to XXXXXX being compiled with. This is all great, but when the templates are complex, it is terribly hard to find the source files in all the mess and double click on them. For example (I have changed the names so the error itself may not make sense, but this is usually what you get):
1>templateClass.h(390) : error C2079: 'STATIC_ASSERT'
1> with
1> [
1> __formal=0
1> ]
1> filename.h(390) : while compiling class template member function 'TestClass<T>::TestClass(void)'
1> with
1> [
1> T=s32
1> ]
1> anotherFilename.cpp(131) : see reference to class template instantiation 'TestClass<T>' being compiled
1> with
1> [
1> T=s32
1> ]
1> yetAnotherFileName.cpp(149) : see reference to function template instantiation 'void Test_TestClass<T>(void)' being compiled
1> with
1> [
1> T=some_policy_class
1> ]
So my question is this: Is there a shortcut to traverse the error stack (is that the right terminology?) for a single error? A shortcut similar to CTRL+SHIFT+F12, which is view next error. Would be great if there is a shortcut for view next file in error.

Bughunting tips for: error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class

I am converting a large VC++ 6.0 application to VS2010 and keep running into this error for one of the projects:
error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ios(176) : see declaration of 'std::basic_ios<_Elem,_Traits>::basic_ios'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_ofstream<_Elem,_Traits>::basic_ofstream(const std::basic_ofstream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
Based on the error text and similar questions asked here, I assume that the error is caused by an instance of ofstream passed directly into a functions, instead of being passed by reference.
The problem I have is, to locate the line of code in which the ofstream is passed in the wrong way. The error message only links to the fstream header included in VS2010 and my project uses ofstream all over the place in a code base of several tens of thousand lines of code (none of which written by me).
I would greatly appriciate any help / tips / strategies to locate this type of compiler error. How would you approach the problem of locating this kind of error?
How would you approach the problem of locating this kind of error?
Do a grep (regex search) in your source files for something like
\(([^,]+,)*, (std::)?of?stream [^&]

Why does Visual Studio 2010 throw this error with Boost 1.42.0?

I'm trying to recompile application, that compiles fine with warning level 4 in visual studio 2005 and visual studio 2008.
Since the errors (look below) are coming from std:tr1, I'm thinking there's some conflict, but not sure how to fix. My first thought was to remove all references to boost, such as but then I get an error that it can't find format method.
So here's one of the errors: (not sure what it means)
Any ideas, suggestions, solutions?
Thanks!
EDIT: Right at the beginning I see a message: Unknown compiler version - please run the configure tests and report the results
EDIT2: Piece of code that I think causes this error: (changed to protect the innocent)
EDIT3: I updated the error message, i.e added more..however I get many more error messages such as this one..so there's a bigger problem/issue.
!m_someMap.insert( std::make_pair( "somestring", SomeClass::isTrue ) ).second
....
.....
inline bool isTrue ( const IDog & dog ) { return s.IsDogTrue(); }
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(197): error C2752: 'std::tr1::_Remove_reference<_Ty>' : more than one partial specialization matches the template argument list
1> with
1> [
1> _Ty=bool (__cdecl &)(const IDog &)
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtr1common(356): could be 'std::tr1::_Remove_reference<_Ty&&>'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtr1common(350): or 'std::tr1::_Remove_reference<_Ty&>'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(962) : see reference to class template instantiation 'std::tr1::remove_reference<_Ty>' being compiled
1> with
1> [
1> _Ty=bool (__cdecl &)(const IDog &)
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(26) : see reference to class template instantiation 'std::tr1::decay<_Ty>' being compiled
1> with
1> [
1> _Ty=bool (__cdecl &)(const IDog &)
1> ]
1> C:\(PATH)\...(915) : see reference to class template instantiation 'std::tr1::_Unrefwrap<_Type>' being compiled
1> with
1> [
1> _Type=bool (__cdecl &)(const IDog &)
1> ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(965): error C2528: 'abstract declarator' : pointer to reference is illegal
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(349): error C2528: 'type' : pointer to reference is illegal
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(967) : see reference to class template instantiation 'std::tr1::add_pointer<_Ty>' being compiled
1> with
1> [
1> _Ty=bool (__cdecl &)(const IDog &)
1> ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(197): error C2752: 'std::tr1::_Remove_reference<_Ty>' : more than one partial specialization matches the template argument list
1> with
1> [
1> _Ty=bool (__cdecl &)(const char *,int,const char *,std::string &)
1> ]
the problem is with visual studio 2010, or I should say that with additional templates that were added to visual studio 2010 tr1, so, std::make_pair, doesn't always work. changed to pair<> and all errors magically went away.
so, if you have template problems in VC2010 and using std:make_pair, change it to pair<> and specify template parameters.
It sounds like Visual Studio might be doing something you don't know. I think you can use the Microsoft compiler with the code::blocks IDE. You can try each compiler (VS 2005/2008/2010). Also, try a diff from your source code repository to be sure Microsoft didn't "prettify" your code.
Note: You don't have to use Code::Blocks after you figure out the problem. It just might be a good tool for this particular issue.