I have two projects with almost the same configuration in visual studio 2010
One with the console works and gives no trouble with the statement
SharedAppenderPtr myAppender(new FileAppender("myLogFile.log"));
While the other project a dll project gives trouble with the same statement
SharedAppenderPtr myAppender(new FileAppender("myLogFile.log"));
The error message is:
Error 3 error C2664: 'log4cplus::FileAppender::FileAppender(const log4cplus::tstring &,std::ios_base::openmode,bool)' : cannot convert parameter 1 from 'const char [10]' to 'const log4cplus::tstring &'
Any suggestions on how I could resolve this issue ?
Try wrapping the "myLogFile.log" like this: LOG4CPLUS_TEXT("myLogFile.log"). You could also use the _T() macro, since you are on Windows with Visual Studio.
I don't know what type log4cplus::tstring is but assuming it is a typedef for a type similar to std::basic_string<cT> (possibly even std::basic_string<cT> with a type cT other than char) you might try one of these:
SharedAppenderPtr app1(new FileAppender(L"myLogFile.log"));
std::string name("myLogFile.log");
SharedApppenderPtr app2(new FileAppender(log4cplus::tstring(name.begin(), name.end())));
Related
I am using third party code(openssl) from our product code. While compiling the code, I am getting the errors which can be suppressed as warnings using -fpermissive flag in Linux (gcc/g++). In windows, I am getting the same compilation errors in visual studio (2005). Would like to know the alternative of -fpermissive flag that can be used in visual studio to suppress the errors.
I tried adding the flags such as '/fpermissive' , '/Ze' in module properties->C/C++->command Line->Additional options. But it did not resolve the problem.
Getting the errors like below.
ssl/packet_locl.h(429) : error C2440: '=' : cannot convert from 'void *' to 'unsigned char 'Conversion from 'void' to pointer to non-'void' requires an explicit cast
Since it is giving error in third party code, we can not make any code changes there.
Expected results: We need to suppress this error as warning and then proceed with compilation successfully.
>>I tried adding the flags such as '/fpermissive' , '/Ze' in module properties->C/C++->command Line->Additional options.
That is define on gcc, you cannot use on VS. This is not suitable for VS.
>>cannot convert from 'void *' to 'unsigned char 'Conversion from 'void' to pointer to non-'void' requires an explicit cast
These are errors defined by the language. You can't ignore these errors and run the program directly. They cannot be compiled.
>>Since it is giving error in third party code, we can not make any code changes there.
If you strictly abide by the method to use the interfaces of these third party libraries, There will be no such errors. What your need is modifying your own code, not changing the third party library code.
I found a nice tutorial on how to implement LuaPlus into an C++ Project using Visual Studio 2010.
http://www.zynox.net/luaplus-1-compiling-basic-usage/
But I can't get it to work because of some error messages..
mainproject\main.cpp(51): error C2664: ‘GetCurrentDirectoryW’ : cannot convert parameter 2 from ‘char [260]‘ to ‘LPWSTR’
50. char pPath[ MAX_PATH ];
51. GetCurrentDirectory(MAX_PATH,pPath);
52. strcat_s(pPath,MAX_PATH,"\\test.lua");
I tried to use TCHAR instead of char, but then it says:
no instance of overloaded function “strcat_s” matches the argument list
So for testing purposes I just deleted these three lines and replaced them with a static path:
const char* pPath = "C:\\Users\\fancyBubble\\Documents\\Visual Studio 2010\\Projects\\LuaPlusTutorial\\MainProject\\test.lua";
and now I get:
fatal error LNK1104: cannot open file ‘..\Debug\LUAPlus.lib’
I'm absolutely clueless how to fix this.
I even tried to use the same version of LuaPlus that the tutorial-creator probably used, but the error messages didn't go away.
I don't really know what I did wrong, but the admin uploaded the whole solution:
http://www.zynox.net/?wpfb_dl=3
Using this combined with greatwolf's comment it works great. :)
Trying to compile this old VC++ 6.0 program in VC++ 2010. This ATL/WTL stuff is giving me lots of problems. I downloaded and have linked to the latest WTL (as far as I know) wtl71.
I am getting compile errors in atlmisc.h:
atlmisc.h(1159): error C2440: 'return' : cannot convert from 'const char *' to 'TCHAR *'
I've searched the 'net, and the answers that come up call for modifying the stock MS atlmisc.h file!
Am I missing something here? What do I need to do to get this to compile?
Most of the time I've seen that error, it's because I've been trying to build a Unicode application. In a Unicode application, the TCHAR* is a short* or wchar_t* rather than a char*.
I'd suggest checking your project settings and making sure that in the project properties, General > Character Set is set to Use Multi-Byte Character Set.
I am trying to port a VC++ application which worked on VS 2003 to VS 2010.
In one of the projects, after converting to VS2010 format, while compiling I get following error in atlbase.h:-
2>C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlbase.h(5137):
error C2664: '__noop' : cannot convert parameter 1 from 'bool' to 'LPWSTR'
The line in question is :-
ATLENSURE(data.hEvent != NULL);
I am building for Unicode char set although I have also tried Multi-byte but in vain.
I have tried figuring this out and searching on relevant forums but no luck yet.
Any help is appreciated, please feel free to ask for more details.
EDIT
After seeing the comment below, I tried commenting this line and the error now occurs at line no 747 in atlbase.h which is
ATLASSUME( m_p == NULL );
If I comment even this then same error occurs somewhere else (in a different file in fact).
I obviously can't modify atlbase.h, Does anyonw have any idea for resolving this?
Please try to build with "no-set" option for your project and all projects it's dependent on, it could help.
I am getting a compilation error when trying to build a C++ project which previously worked.
The code follows:
const wchar_t* pdest;
pdest = _tcsstr(ConnStr, Name);
The error follows:
Error 10 error C2440: '=' : cannot convert from 'const char *' to 'const wchar_t
I'm using Visual Studio 2008. The error message explains the problem well, but I know this program used to compile, what am I doing wrong?
Your code is dangerous. _tcsstr is a TCHAR macro, so it's definition can change depending on whether or not UNICODE is defined. wchar_t is fixed. The error you're seeing is due to this exact problem - the environment is using the single-byte version of _tcsstr (likely becasue UNICODE is not defined).
Don't just define UNICODE. Fix the code first. Either use TCHAR macros for both, or the wide character functions.
_tcsstr is for use with TCHAR. Depending on compile settings, this is either char or wchar_t.
So either use TCHAR, or wcsstr
That should fix this issue:
Property -> Configuration Properties -> General -> Character Set : Use multi-Byte Character Set.