Pelles C forum

C language => Work in progress => Topic started by: frankie on March 30, 2014, 09:46:38 PM

Title: Instructions to use MS standard headers on PellesC
Post 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:

What you have to do is:
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).
Title: Re: Instructions to use MS standard headers on PellesC
Post by: frankie on April 05, 2014, 04:23:23 PM
This is the manual procedure (if you want do it yourself):
Code: [Select]
//          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:
Code: [Select]
#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:
Code: [Select]
#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:
Code: [Select]
extern "C" IEnroll * WINAPI PIEnrollGetNoCOM(void);
extern "C" IEnroll2 * WINAPI PIEnroll2GetNoCOM(void);
extern "C" IEnroll4 * WINAPI PIEnroll4GetNoCOM(void);
with:
Code: [Select]
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:
Code: [Select]
#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
Code: [Select]
        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
Code: [Select]
        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
Code: [Select]
        BYTE    Info[0];                //... information field.
        WORD    RoutingInfo[0];         //... routing information field.
to
Code: [Select]
        BYTE    *Info;                //... information field.
        WORD    *RoutingInfo;         //... routing information field.
Line 4846 change
Code: [Select]
      RouterAE RAE[];
to
Code: [Select]
      RouterAE *RAE;
----------------------------------------------------------------------------------------------------------------------------
[CertPolEng.h]
Requires other file inclusion and a definition:
Code: [Select]
#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
Code: [Select]
EXTERN_C typedef HRESULT (STDAPICALLTYPE *LPDAOBINDFUNC)(ULONG cb, DWORD dwUser, LPVOID *ppData);
to
Code: [Select]
#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
Code: [Select]
#endif      _ST_SRVR_H_
to
Code: [Select]
#endif      //_ST_SRVR_H_
Line 1047 change
Code: [Select]
#else MIDL_PASS
to
Code: [Select]
#else //MIDL_PASS
Line 1052 change
Code: [Select]
#endif MIDL_PASS
to
Code: [Select]
#endif //MIDL_PASS
----------------------------------------------------------------------------------------------------------------------------
[dhcpv6csdk.h]
Requires 'time.h' before it.
Line 70 change
Code: [Select]
#endif  DHCPV6_OPTIONS_DEFINED
to
Code: [Select]
#endif  //DHCPV6_OPTIONS_DEFINED
Line 83 change
Code: [Select]
#endif DHCPV6API_PARAMS_DEFINED
to
Code: [Select]
#endif //DHCPV6API_PARAMS_DEFINED
Line 189 change
Code: [Select]
#endif _DHCPV6CSDK_
to
Code: [Select]
#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
Code: [Select]
  STDMETHOD(Commit)(THIS_ ) PURE;
to
Code: [Select]
  STDMETHOD(Commit)(void) PURE;
Line 266 change
Code: [Select]
  STDMETHOD(End)(THIS_) PURE;
to
Code: [Select]
  STDMETHOD(End)(void) PURE;
----------------------------------------------------------------------------------------------------------------------------
[DSClient.h]
Requires 'shlobj.h'
----------------------------------------------------------------------------------------------------------------------------

Comment Lines 114 & 115
Code: [Select]
EXTERN_C
{
to
Code: [Select]
//EXTERN_C
//{
Comment line 216
Code: [Select]
}
to
Code: [Select]
//}
Line 224 Add comment after #endif
Code: [Select]
#endif __DTCHELP_H__
to
Code: [Select]
#endif //__DTCHELP_H__
----------------------------------------------------------------------------------------------------------------------------
[dvbsiparser.h]
Line 1161 Function polymorphism
Code: [Select]
        HRESULT ( STDMETHODCALLTYPE *GetSDT )(
to
Code: [Select]
        HRESULT ( STDMETHODCALLTYPE *GetSDT2 )(
Line 7832 Function polymorphism
Code: [Select]
        HRESULT ( STDMETHODCALLTYPE *GetServiceProviderNameW )(
to
Code: [Select]
        HRESULT ( STDMETHODCALLTYPE *GetServiceProviderNameExW )(
Title: Re: Instructions to use MS standard headers on PellesC
Post by: frankie on April 06, 2014, 05:41:32 PM
For someone who just want to just test WSDK with separated copy of PellesC.
make these changes to Pellesc ctype.h
Quote
#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.
Title: Re: Instructions to use MS standard headers on PellesC
Post by: frankie on April 27, 2014, 07:20:34 PM
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.
Title: Re: Instructions to use MS standard headers on PellesC
Post by: frankie on April 30, 2014, 12:54:25 PM
Working version 1.25 available on the first post of the thread.
Tested on X86 and X64.
Please report bugs.