-
August 10th, 2015, 02:34 AM
#1
Problem while converting from 32-bit to 64-bit
I have an MS Office addin using ATL COM. It is working fine, but I want that DLL to run on MS Office 64bit too. For that I went to configuration manager added a new combiler that is X64.
But after changing to X64, these are the errors that I am coming across these errors. Can someone help me with this?
Code:
Error 2 error C4235: nonstandard extension used : '__asm' keyword not supported on this architecture c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 396
Error 3 error C2065: 'fld' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 4 error C2146: syntax error : missing ';' before identifier 'dValue' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 5 error C2146: syntax error : missing ';' before identifier 'fadd' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 6 error C2065: 'fadd' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 7 error C2146: syntax error : missing ';' before identifier 'st' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 8 error C2065: 'st' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 9 error C2146: syntax error : missing ';' before identifier 'fadd' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 400
Error 10 error C3861: 'st': identifier not found c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 11 error C2146: syntax error : missing ';' before identifier 'round_to_nearest' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 401
Error 12 error C2146: syntax error : missing ';' before identifier 'fistp' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 401
Error 13 error C2065: 'fistp' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 14 error C2146: syntax error : missing ';' before identifier 'i' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 15 error C2146: syntax error : missing ';' before identifier 'sar' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 16 error C2065: 'sar' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 17 error C2146: syntax error : missing ';' before identifier 'i' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 18 error C2143: syntax error : missing ';' before '}' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 403
Error 21 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 59 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 63 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 66 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 68 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 70 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 72 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
-
August 10th, 2015, 03:23 AM
#2
Re: Problem while converting from 32-bit to 64-bit
Victor Nijegorodov
-
August 11th, 2015, 02:21 AM
#3
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by VictorN
Thanks for the link. But it didn't help me in resolving the problem in this context. The problems are too much. There are 2 areas where I am facing issue. I have a callback function.
Code:
static DWORD CALLBACK StreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
DWORD dwRead(0);
if(SUCCEEDED(g_pTextFile->Read(pbBuff, cb, dwRead)))
{
*pcb = LONG(dwRead);
return 0;
}
return 1;
}
Which when called in the OnInitDialog
Code:
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CAxDialogImpl<CLicenseBox>::OnInitDialog(uMsg, wParam, lParam, bHandled);
m_richEdit = GetDlgItem(IDC_RICHEDIT21);
WCHAR szBuffer[1024];
CUtils::BuildHomeDirectoryPath(szBuffer, 1024, L"eula.rtf");
if(SUCCEEDED(g_pTextFile->CreateR(szBuffer)))
{
EDITSTREAM es;
ZeroMemory(&es, sizeof(EDITSTREAM));
es.pfnCallback = StreamInCallback;
m_richEdit.StreamIn(SF_RTF, es);
}
else
{
m_richEdit.ReplaceSel(CUtils::GetResourceString_(IDS_MSG_FILENOTFOUND).c_str());
}
CButton button = GetDlgItem(IDC_BUTTON1);
button.SetFocus();
SetWindowText(CUtils::GetResourceString_(IDS_GUI_END_USER_LICENSE_AGREEMENT).c_str());
SetDlgItemText(IDC_BUTTON1, CUtils::GetResourceString_(IDS_REPORT_CLOSE).c_str());
HICON hIcon = (HICON)LoadImage(_AtlModule.GetResourceInstance(),
MAKEINTRESOURCE(IDI_ICON1),
IMAGE_ICON,
GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON),
LR_DEFAULTCOLOR);
SetIcon(hIcon, TRUE);
HICON hIconSmall = (HICON)LoadImage(_AtlModule.GetResourceInstance(),
MAKEINTRESOURCE(IDI_ICON1),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
LR_DEFAULTCOLOR);
SetIcon(hIconSmall, FALSE);
return 1;
}
Throws this error. Multiple times in 64-bit.
Error 1 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 2 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 3 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 4 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 5 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 6 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Error 44 error C2440: '=' : cannot convert from 'DWORD (__cdecl *)(DWORD,LPBYTE,LONG,LONG *)' to 'EDITSTREAMCALLBACK' c:\maverick\projects\ccpm\src\main_ccpm_11.0.0.7\LicenseBox.h 70
Can it be manually corrected by making change or some kind of typecasting?
-
August 11th, 2015, 02:24 AM
#4
Re: Problem while converting from 32-bit to 64-bit
The other problem is in this section of the code.
Code:
__asm
{
fld dValue
fadd st, st (0)
fadd round_to_nearest
fistp i
sar i, 1
}
It throws this error.
Error 45 error C4235: nonstandard extension used : '__asm' keyword not supported on this architecture c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 396
Error 46 error C2065: 'fld' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 47 error C2146: syntax error : missing ';' before identifier 'dValue' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 48 error C2146: syntax error : missing ';' before identifier 'fadd' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 49 error C2065: 'fadd' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 50 error C2146: syntax error : missing ';' before identifier 'st' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 51 error C2065: 'st' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 52 error C2146: syntax error : missing ';' before identifier 'fadd' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 400
Error 53 error C3861: 'st': identifier not found c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 399
Error 54 error C2146: syntax error : missing ';' before identifier 'round_to_nearest' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 401
Error 55 error C2146: syntax error : missing ';' before identifier 'fistp' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 401
Error 56 error C2065: 'fistp' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 57 error C2146: syntax error : missing ';' before identifier 'i' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 58 error C2146: syntax error : missing ';' before identifier 'sar' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 59 error C2065: 'sar' : undeclared identifier c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 60 error C2146: syntax error : missing ';' before identifier 'i' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 402
Error 61 error C2143: syntax error : missing ';' before '}' c:\Maverick\Projects\CCPM\SRC\Main_CCPM_11.0.0.7\Utils.cpp 403
Can the code change correct this small issue?
-
August 11th, 2015, 02:39 AM
#5
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by maverick786us
Thanks for the link. But it didn't help me in resolving the problem in this context. The problems are too much. There are 2 areas where I am facing issue. I have a callback function.
Code:
static DWORD CALLBACK StreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
DWORD dwRead(0);
if(SUCCEEDED(g_pTextFile->Read(pbBuff, cb, dwRead)))
{
*pcb = LONG(dwRead);
return 0;
}
return 1;
}
According to MSDN the StreamInCallback has the following signature:
Code:
DWORD CALLBACK EditStreamCallback(
_In_ DWORD_PTR dwCookie,
_In_ LPBYTE pbBuff,
_In_ LONG cb,
_In_ LONG *pcb
);
Victor Nijegorodov
-
August 11th, 2015, 02:42 AM
#6
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by maverick786us
The other problem is in this section of the code.
Code:
__asm
{
fld dValue
fadd st, st (0)
fadd round_to_nearest
fistp i
sar i, 1
}
It throws this error.
Can the code change correct this small issue?
Well the error code tells you very clear:
Error 45 error C4235: nonstandard extension used : '__asm' keyword not supported on this architecture
and the same problem was discussed in the forum the link to which I posted.
Victor Nijegorodov
-
August 11th, 2015, 02:44 AM
#7
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by VictorN
Well the error code tells you very clear:and the same problem was discussed in the forum the link to which I posted.
What is the replacement to __asm in 64-bit?
-
August 11th, 2015, 02:50 AM
#8
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by maverick786us
What is the replacement to __asm in 64-bit?
There is no one. You must implement everything in C/C++ for both architectures, or introduce conditional compilation parts per architecture having C/C++ code intended for 64-bit part.
Last edited by Igor Vartanov; August 11th, 2015 at 02:54 AM.
Best regards,
Igor
-
August 11th, 2015, 06:52 AM
#9
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by Igor Vartanov
There is no one. You must implement everything in C/C++ for both architectures, or introduce conditional compilation parts per architecture having C/C++ code intended for 64-bit part.
Well not entirely true.
there is no __asm, but that doesn't mean you can only use C/C++
the solution is if you must have bits of assembly, you'll need to put those in a separate .asm file and use an assembler to create the object file from that, then add the object to your linker step or turn the object(s) into a library and add the library to your linker step.
that being said, I see a LOT of __asm that shouldn't have been written in assembly in the first place and should just have been C/C++ code. Lots of people think they can outsmart a compiler at producing machine code, but that's rarely the case. Beating a compiler with a sufficient lead to have made the extra effort worthwhile is given to only a few individuals.
Being able to use specific machine instructions (like the string functions, large integer math (handling carry), MMX, SSE, ...) is where you can often beat a compiler, but even there, many compiler libraries now have intrinsics or helper functions to give you access to those features without the need for assembly.
So if possible, get rid of the _asm, but if you need it, you'll need an external assembler for Win64.
-
August 20th, 2015, 06:03 AM
#10
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by VictorN
According to MSDN the StreamInCallback has the following signature:
Code:
DWORD CALLBACK EditStreamCallback(
_In_ DWORD_PTR dwCookie,
_In_ LPBYTE pbBuff,
_In_ LONG cb,
_In_ LONG *pcb
);
The problem is. The source code is in old VS2005, where The EditStreamCallback
Code:
typedef struct _editstream
{
DWORD_PTR dwCookie; // User value passed to callback as first parameter
DWORD dwError; // Last error
EDITSTREAMCALLBACK pfnCallback;
} EDITSTREAM;
inside "richedit.h". which resides in the old platform SDK folder.
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Include
-
August 20th, 2015, 08:43 AM
#11
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by maverick786us
The other problem is in this section of the code.
Code:
__asm
{
fld dValue
fadd st, st (0)
fadd round_to_nearest
fistp i
sar i, 1
}
difficult to be sure. assuming i is of type int... (could also be a 64bit int or a 16bit int, adjust the code to match the type of i)
Code:
i = static_cast<int>(dValue+dValue+round_to_nearest) / 2;
and this prooves EXACTLY what I said earlier about trying to outsmart the compiler. This should never have been written as an __asm block in the first place. The C++ code will outperform the assembly in almost all usage cases because the compiler is left free to reorganise the instructions to interleave, where it can't do that with the __asm block.
-
August 20th, 2015, 08:47 AM
#12
Re: Problem while converting from 32-bit to 64-bit
Originally Posted by maverick786us
inside "richedit.h". which resides in the old platform SDK folder.
Also quite "easy": you cannot use a platform SDK that predates Win64 to produce Win64 code.
Update to a newer platform SDK (might be tricky to find one that will work on an older compiler).
And/or update to a newer compiler.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|