Pelles C forum
C language => Work in progress => Topic started by: frankie on March 30, 2014, 09:46:38 PM
-
This utility automatically executes the required setup to use MS header files from SDK-V7.1 distribution.
To use the utility you need an installed copy of MS SDK V.7 on your machine.
The tool automatically:
- Backup your current PellesC include directory & files
- Copy MS Headers from your SDK-7.1 installation to PellesC include
- Patch the headers files.
What you have to do is:
- Download the tool MS-Headers.zip from this post, create a folder on your PC wherever you like and unzip the tool.
- Doubleclick the executable 'MS-Headers.exe'. It detects automatically the location for SDK and PellesC installations, if they are not correct you can change them manually using the buttons on the right of the address.
- When ready press 'Copy Files' button.
- The process will automaticalli create a back-up named C:\<your PellesC location>\PellesC\Include\Win.BAK with original files. If a backup already exist you will be asked for overwrite.
- Then it will copy files from SDK.
- When the copy is complete you will be asked if you want proceed with patching. Answer yes.
- After patching is complete you will be asked again if you want read the process log. Press yes if you want, it will show a txt file with a list of copyied files.
- Finished!
Now you can run PellesC and compile your programs ...
For advanced users, you can also specify a different directory for the copy without overwriting the original PellesC Include\Win. In this case you can select the directory to use for compilations changing them globally using Tools->options folders, or locally for a project changing Project options->Folders.
The Patch doesn't mask any warning. For a full detail of patches you can look into the file 'diffs.txt' that contains the modifications in patch format (as generated from diff or windiff).
-
This is the manual procedure (if you want do it yourself):
- Copy files from sdk to PellesC
- Get a copy of sal.h from VC or DDK or from here (http://forum.pellesc.de/index.php?topic=6136.msg22755#msg22755).
- Edit 'driverspecs.h' in a text editor, start the text replacement box then replace all
occourrences of "(##__drv_nop" with "(__drv_nop". Then save the file. - Now edit 'ShellApi.h', locate the line
// PATH = c:\windows\system32;C:\windows;c:\;C:\Program Files\Compilers\
Then add a space at the end of line and save the file.
10. Now edit 'stralign.h' and locate this code:
#if _STRALIGN_USE_SECURE_CRT
#define ua_wcscpy_s wcscpy_s
#endif
__inline
PUWSTR
static
_WINDOWS_INSECURE_DEPRECATE
ua_wcscpy(
__out_xcount("Sufficient length") PUWSTR Destination,
__in PCUWSTR Source
)
{
#pragma warning(push)
#pragma warning(disable:4995)
#pragma warning(disable:4996)
#ifdef _PREFAST_
#pragma warning(disable:__WARNING_BANNED_API_USAGE) // This function (ua_wcscpy) is also tagged as insecure and deprecated
#endif // _PREFAST_
return wcscpy(Destination, Source);
#pragma warning(pop)
}
Add inclusion of 'wchar.h' as below:
#if _STRALIGN_USE_SECURE_CRT
#define ua_wcscpy_s wcscpy_s
#endif
#include <wchar.h> //You have to add *only* this line
__inline
PUWSTR
static
_WINDOWS_INSECURE_DEPRECATE
ua_wcscpy(
__out_xcount("Sufficient length") PUWSTR Destination,
__in PCUWSTR Source
)
{
#pragma warning(push)
#pragma warning(disable:4995)
#pragma warning(disable:4996)
#ifdef _PREFAST_
#pragma warning(disable:__WARNING_BANNED_API_USAGE) // This function (ua_wcscpy) is also tagged as insecure and deprecated
#endif // _PREFAST_
return wcscpy(Destination, Source);
#pragma warning(pop)
}
Save the file.
11. Edit file 'Xenroll.h', replace the lines:
extern "C" IEnroll * WINAPI PIEnrollGetNoCOM(void);
extern "C" IEnroll2 * WINAPI PIEnroll2GetNoCOM(void);
extern "C" IEnroll4 * WINAPI PIEnroll4GetNoCOM(void);
with:
EXTERN_C IEnroll * WINAPI PIEnrollGetNoCOM(void);
EXTERN_C IEnroll2 * WINAPI PIEnroll2GetNoCOM(void);
EXTERN_C IEnroll4 * WINAPI PIEnroll4GetNoCOM(void);
12. PellesC starting from V.5.00 impersonate itself as _MSC_VER=1100, but miss some storage-class information specifiers, defined using the keyword '__declspec'.
When using standard headers same specifiers (usefull only to C++ and for this reason not present in PellesC) are used triggering warnings. To avoid the warnings edit 'windows.h' and add defines as showed:
#ifndef _WINDOWS_
#define _WINDOWS_
#ifdef __POCC__ //Add these 3 lines for PellesC
#define __declspec(selectany) //Add All missing specifiers that you can find
#endif
#include <sdkddkver.h>
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
Up to now we are defining the 'selectany' specifier as nothing. This specifier is used in C++ to override multiple constructors/destructors definitions.
13. You have finished and can start to compile... 8)
The main difference using the original MS headers is the compilation time, this bloated headers requires a lot more time :-\.
Because MS headers doesn't have the #pragma comment(lib, .... in many cases you have to specify manually the libraries needed.
This is a work in progress! You will not be able to compile everything.
I have patched some other files thanks to the Timo's list.
This is only a part as this is a work in progress.
[Mpeg2data.h]
There is a C++ class operator on line 353. Comment out to make it work, but don't know if it is usable
//class DECLSPEC_UUID("DBAF6C1B-B6A4-4898-AE65-204F0D9509A1") Mpeg2DataLib;
----------------------------------------------------------------------------------------------------------------------------
[mpeg2psiparser]
Line 284 Redefinition of 'Initialize' property due to polimorhism change it to 'InitializeWord'
HRESULT ( STDMETHODCALLTYPE *InitializeWord )
Line 289 as above for 'GetLength' change to 'GetLengthWord'
HRESULT ( STDMETHODCALLTYPE *GetLengthWord )
----------------------------------------------------------------------------------------------------------------------------
[axextendenums.h]
You cannot include it together with atscpsipparser.h.
----------------------------------------------------------------------------------------------------------------------------
[netmon.h]
Lines 1422-1427 add space at end of line or surround lines with /* */ comment
Starting from line 2153 change
BYTE Byte[]; //... table of bytes follows
WORD Word[]; //... table of words follows
DWORD Dword[]; //... table of Dwords follows
LARGE_INTEGER LargeInt[]; //... table of LARGEINT structures to follow
SYSTEMTIME SysTime[]; //... table of SYSTEMTIME structures follows
TYPED_STRING TypedString;//... a typed_string that may have extended data
to
BYTE *Byte; //... table of bytes follows
WORD *Word; //... table of words follows
DWORD *Dword; //... table of Dwords follows
LARGE_INTEGER *LargeInt; //... table of LARGEINT structures to follow
SYSTEMTIME *SysTime; //... table of SYSTEMTIME structures follows
Starting from line 3234 change
BYTE Info[0]; //... information field.
WORD RoutingInfo[0]; //... routing information field.
to
BYTE *Info; //... information field.
WORD *RoutingInfo; //... routing information field.
Line 4846 change
RouterAE RAE[];
to
RouterAE *RAE;
----------------------------------------------------------------------------------------------------------------------------
[CertPolEng.h]
Requires other file inclusion and a definition:
#include <schannel.h>
#include <ntsecapi.h>
#include <lsalookup.h>
#define SECURITY_KERNEL
#include <sspi.h>
#include <ntsecpkg.h>
#include <CertPolEng.h>
----------------------------------------------------------------------------------------------------------------------------
[clfs.h]
No errors maybe ok by another fix.
----------------------------------------------------------------------------------------------------------------------------
[daogetrw.h]
Line 85, change
EXTERN_C typedef HRESULT (STDAPICALLTYPE *LPDAOBINDFUNC)(ULONG cb, DWORD dwUser, LPVOID *ppData);
to
#ifdef __cplusplus
EXTERN_C typedef HRESULT (STDAPICALLTYPE *LPDAOBINDFUNC)(ULONG cb, DWORD dwUser, LPVOID *ppData);
#else
typedef HRESULT (STDAPICALLTYPE *LPDAOBINDFUNC)(ULONG cb, DWORD dwUser, LPVOID *ppData);
#endif
----------------------------------------------------------------------------------------------------------------------------
[ddrawgdi.h]
Should require DirectX SDK. To check.
----------------------------------------------------------------------------------------------------------------------------
[dhcpsapi.h]
Conflicts with 'netmon.h' for symbol 'MAX_PATTERN_LENGTH' redefinition (a completely different meaning and value anyway).
There are alot of problems for this header as you can see here (http://msdn.microsoft.com/en-us/library/windows/desktop/aa813375(v=vs.85).aspx)
Line 1020 change
#endif _ST_SRVR_H_
to
#endif //_ST_SRVR_H_
Line 1047 change
#else MIDL_PASS
to
#else //MIDL_PASS
Line 1052 change
#endif MIDL_PASS
to
#endif //MIDL_PASS
----------------------------------------------------------------------------------------------------------------------------
[dhcpv6csdk.h]
Requires 'time.h' before it.
Line 70 change
#endif DHCPV6_OPTIONS_DEFINED
to
#endif //DHCPV6_OPTIONS_DEFINED
Line 83 change
#endif DHCPV6API_PARAMS_DEFINED
to
#endif //DHCPV6API_PARAMS_DEFINED
Line 189 change
#endif _DHCPV6CSDK_
to
#endif //_DHCPV6CSDK_
----------------------------------------------------------------------------------------------------------------------------
[Dispdib.h]
Requires 'windowsx.h'
----------------------------------------------------------------------------------------------------------------------------
[drt.h]
To be included as first before 'windows.h'
----------------------------------------------------------------------------------------------------------------------------
[DSAdmin.h]
Requires 'iads.h' included before.
Line 137 change
STDMETHOD(Commit)(THIS_ ) PURE;
to
STDMETHOD(Commit)(void) PURE;
Line 266 change
STDMETHOD(End)(THIS_) PURE;
to
STDMETHOD(End)(void) PURE;
----------------------------------------------------------------------------------------------------------------------------
[DSClient.h]
Requires 'shlobj.h'
----------------------------------------------------------------------------------------------------------------------------
Comment Lines 114 & 115
EXTERN_C
{
to
//EXTERN_C
//{
Comment line 216
}
to
//}
Line 224 Add comment after #endif
#endif __DTCHELP_H__
to
#endif //__DTCHELP_H__
----------------------------------------------------------------------------------------------------------------------------
[dvbsiparser.h]
Line 1161 Function polymorphism
HRESULT ( STDMETHODCALLTYPE *GetSDT )(
to
HRESULT ( STDMETHODCALLTYPE *GetSDT2 )(
Line 7832 Function polymorphism
HRESULT ( STDMETHODCALLTYPE *GetServiceProviderNameW )(
to
HRESULT ( STDMETHODCALLTYPE *GetServiceProviderNameExW )(
-
For someone who just want to just test WSDK with separated copy of PellesC.
make these changes to Pellesc ctype.h
#ifdef _MSC_EXTENSIONS
/* for compiling with windows.h -- see Microsoft ctype.h */
#ifndef _WCHAR_T_DEFINED
#define _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
#include <wchar.h>
#endif
#pragma warn(disable: 1058 1063) // <-- add this for MS bugs
#ifdef _WIN64
#pragma warn(disable: 2195) // <-- add this for 64 bit
#endif
#endif /* _MSC_EXTENSIONS */
and copy WSDK headers with frankie's tool and libs manually.
-
New version 1.21 of the tool.
Now it backups your installation, copy the required files from SDK 7.1 and patches them.
You can download it from the first post of this thread.
The discussion for this topic is on this (http://forum.pellesc.de/index.php?topic=6136.0) thread.
Known problems: sometimes the file sal.h, which is the patch as a file to add, is not created >:( find a copy below.
When compiling in 64 bits there are many warnings for intrinsic functions not available in PellesC. Will be corrected in next update.
-
Working version 1.25 available on the first post of the thread.
Tested on X86 and X64.
Please report bugs.