PDA

View Full Version : Qt application Compiling with ATL library Plroblem



a.srikant.reddy
9th May 2011, 15:26
Hello ,
I am getting problem in compiling ATL project with Qt application.

I m getting below errors

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(5086) : error C2664: 'ATL::CRegKey::QueryStringValue' : cannot convert parameter 2 from 'TCHAR [64]' to 'LPTSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(5095) : error C2664: 'T2OLE_EX' : cannot convert parameter 1 from 'TCHAR [64]' to 'LPTSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(5261) : error C2664: 'RegEnumKeyExW' : cannot convert parameter 3 from 'TCHAR [256]' to 'LPWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(5261) : fatal error C1903: unable to recover from previous error(s); stopping compilation

Could anyone please help me out.

Thanks in Advance
Srikant

ChrisW67
10th May 2011, 07:10
The errors are because you are passing incompatible data to the respective routines. It is not immediately obvious how you arrive at these specific errors. Since you don't bother to show us the lines in your code that triggered these messages we cannot really help.

If you still cannot nut it out, and since this has nothing to do with Qt, you are better off looking for Microsoft and ATL resources and forums:
http://msdn.microsoft.com/en-us/library/b2wz0ekh%28v=VS.90%29.aspx
http://msdn.microsoft.com/en-us/library/dd374131%28v=VS.85%29.aspx
http://groups.google.com/group/microsoft.public.vc.atl/topics

a.srikant.reddy
10th May 2011, 08:30
Hi , Thank you for your reply. But i'm trying to build few files in a new solution. The problem is that i have added these files in a new solution and on trying to build it, iam getting these errors. Though what i found is that few of these files have ATl dependency. But i was not able to find out what is causing this error. Actually this error is coming on compilation of a file, which on checking out i found that it has no dependecy with ATL. You can find few more description:

1) The project is in QT
2) I am trying to put certain files which actually has ATl dependency into a new solution.

ChrisW67
11th May 2011, 09:13
The error is caused by the code you added to your project. You are not showing the code so we have no hope of correcting the error. It could be simple as compiling with/without the UNICODE/_UNICODE defines or it may be just broken code.

The error is clearly caused by passing improper arguments to an MFC or ATL class, or Windows API calls. The original cpp file must, therefore, have a dependency on MFC, ATL and Windows API headers/classes whether you intended it to or not. The particular methods are:


// From ATL
LONG QueryStringValue(
LPCTSTR pszValueName,
LPTSTR pszValue,
ULONG* pnChars
) throw( );

// From Windows API (the Wide version of this)
LONG WINAPI RegEnumKeyEx(
__in HKEY hKey,
__in DWORD dwIndex,
__out LPTSTR lpName,
__inout LPDWORD lpcName,
__reserved LPDWORD lpReserved,
__inout LPTSTR lpClass,
__inout_opt LPDWORD lpcClass,
__out_opt PFILETIME lpftLastWriteTime
);


The project might have Qt components but the problem is not related to Qt.

Added after 6 minutes:

Does your code around the first call look anything like this?

ATL::CRegKey regkey(...);
TCHAR somebuffer[64];
LONG nChars = 64;
...
LONG ret = regkey.QueryStringValue("valuename", *somebuffer, &nChars);

If so, drop the asterisk in the method arguments.

joshspain
1st September 2011, 20:56
I ran into this problem also. In my .pro file I had set:


win32: CharacterSet=2

I did this to enable multi-byte character set in my Visual Studio project. However, this does not remove the "UNICODE" preprocessor directive from the project. You have to remove it manually by doing this:


win32: DEFINES -= UNICODE

Normally I wouldn't set a Qt project to multi-byte, but I was trying to get a small unit test project going with some existing code that was dependent on multi-byte character set.