VS2012 Compile as x64

I apologize for my lack of knowledge but that's why i'm here. I am a .net developer don't all boo and hiss... :-) but am working on a project with MS Host Integration Server and printing. Within HIS you can define print filter DLLs (must be C++) that allow you to append data to the print stream: http://msdn.microsoft.com/en-us/library/gg164794.aspx I have been able to compile the example (slightly modified) in VS2012 for a 32bit architecture but our target platform in x64 and when I try to compile it as best i know how for 64 bit I get an warning C4090: 'function' : different '__unaligned' qualifiers C:\Program Files (x86)\Windows Kits\8.0\Include\shared\stralign.h and now am clueless....

The dll is really simple see code below but i fear my lack of knowledge on how to compile this correctly is causing the problems, I will also make it even simpler when i take out all the trace code, but will leave it in for the time being to help me work out whats going on.

Any assistance will be gratefully received. Thanks in advance. Steve

---NTFilter.h---
#include <windows.h>
#include <stdio.h>

#define SIZEBUF 4096

__declspec( dllexport ) void * WINAPI PrtFilterAlloc(DWORD Buflen);
__declspec( dllexport ) void WINAPI PrtFilterFree(void *pBuf);
__declspec( dllexport ) void * WINAPI PrtFilterJobStart(char *SessionName,DWORD LUType,char** pBufPtr,DWORD *pBuflen);
__declspec( dllexport ) void WINAPI PrtFilterJobData(void *UniqueID, char **pBufPtr,DWORD *pBufLen);
__declspec( dllexport ) void * WINAPI PrtFilterJobEnd(char *SessionName,char** pBufPtr,DWORD *pBuflen);

BOOL APIENTRY DllMain( HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved );

void trace(char *text);
-------
---NTFilter.c---
/*

/* NtFilter.c
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* This sample illustrates using the Host Integration Server
* print filter APIs
*
*/

#include "NtFilter.h"


int SessId =156789;
void * Uid = (void *)&SessId ;
FILE *f;


BOOL APIENTRY DllMain( HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved )
{
switch( ul_reason_for_call )
{
case DLL_PROCESS_ATTACH:
trace("Initialization - Process Attach");
break;
case DLL_THREAD_ATTACH:
trace("Thread Attach");
break;
case DLL_THREAD_DETACH:
trace("Thread Detach");
break;
case DLL_PROCESS_DETACH:
trace("Process Detach");
break;
}
return TRUE;
}

__declspec( dllexport ) void * WINAPI PrtFilterAlloc(DWORD BufLen)
{
/* MSFT - 3 lines for Debug OutPut - START */
void * pBuf ;
char TrBuf[50] ;
trace("FilterAlloc");
/* MSFT - 3 lines for Debug OutPut - END */

pBuf = malloc(BufLen) ;

/* MSFT - 2 lines for Debug OutPut - START */
sprintf_s (TrBuf, _countof(TrBuf), "%x ",pBuf);
trace (TrBuf) ;
/* MSFT - 2 lines for Debug OutPut - END */

return(pBuf);
}

__declspec( dllexport ) void WINAPI PrtFilterFree(void *pBuf)
{
/* MSFT - 4 lines for Debug OutPut - START */
char TrBuf[50] ;
trace("FilterFree");
sprintf_s (TrBuf,_countof(TrBuf), "%x ",pBuf);
trace (TrBuf) ;
/* MSFT - 4 lines for Debug OutPut - END */

free(pBuf);

/* MSFT - 1 line for Debug OutPut - START */
trace(" Buffer library");
/* MSFT - 1 line for Debug OutPut - END */

return;
}

__declspec( dllexport ) void WINAPI PrtFilterJobData(void *UniqueID, char **pBufPtr,DWORD *pBufLen)
{
/* MSFT - 4 lines for Debug OutPut - START */
char TrBuf[50] ;
trace("FilterJobData");
sprintf_s (TrBuf, _countof(TrBuf), "%d ",*pBufLen);
trace (TrBuf) ;
/* MSFT - 4 lines for Debug OutPut - END */

return;
}

__declspec( dllexport ) void * WINAPI PrtFilterJobStart(char *SessionName, DWORD LUType, char** pBufPtr, DWORD *pBufLen)
{
/* MSFT - 1 line for Debug OutPut - START */
trace("FilterJobStart");
/* MSFT - 1 line for Debug OutPut - END */
strcpy_s(*pBufPtr, 2, "-|" );
strcpy_s(*pBufPtr, _countof(pBufPtr), SessionName );
strcpy_s(*pBufPtr, 2, "|-" );
*pBufLen=(DWORD)strlen(*pBufPtr);

return((void *)(Uid));
}

__declspec( dllexport ) void * WINAPI PrtFilterJobEnd(char *SessionName,char** pBufPtr,DWORD *pBufLen)
{
/* MSFT - 1 line for Debug OutPut - START */
trace("FilterJobEnd");
/* MSFT - 1 line for Debug OutPut - END */

return((void *)(Uid));
}

void trace(char *text)
{
errno_t err;
err = fopen_s ( &f, "c:\\trfilter.txt","a+t");
fprintf(f,"NTFILTER : %s \n",text);
fclose(f);
}
--------
C:\Program Files (x86)\Windows Kits\8.0\Include\shared\stralign.h
From the looks of it, you're using the x86 SDK instead of the x86-64.
Thanks for the response, i will try to install the latest SDK and let you know it goes.
Ive managed to get that to go away but now get

Error 10 error C2011: '_CONTEXT' : 'struct' type redefinition c:\Program Files\Microsoft SDKs\Windows\v7.1\include\winnt.h 4193 1 ntfilter

Any Ideas?
Apparently, this can happen if _X86_ is in the list of predefined macros. How did you move the project to x64? The correct way is to go to Configuration Manager, and on the combobox in the Platform column, select New; then in the new dialog that appears select New platform: x64 and Copy settings from: Win32.
If you did anything else, revert your changes to before you started working with x64 (it helps if you're using version control) and do it this way.
Topic archived. No new replies allowed.