www.digitalmars.com         C & C++   DMDScript  

c++.windows - windows sdk update

I have a program which I could not compile with dmc because  a windows service
interface was added. I could solve it by fetching winsvc.h from mingw.
The result was that I had files from 2 distrubutions and they are from
different versions.
I tried ms sdk 7.1 but that caused a lot of grief and with files in the
I deceided to go with win32api from mingw.org. I enclose the recepy in the hope
it is a)useful for someone b) maybe someone can improve on it.

I looked at kernel32.def on dsource.org and modeled the defs after that.
implib didn't like the keyword DATA so I left them out! Maybe someone knows how
to apply that.
Also gcc has pragma aux and offcourse dmc complains. I didn't plan on editing
the header files, more then neccesary. Again maybe someone can come up with an,
automated, strategy. 


start cmd.exe menu-->run type cmd
mkdir c:\sdk
mkdir c:\dm\def
mkdir c:\dm\def\ddk
mkdir c:\dm\lib\ddk
mkdir c:\dm\def\directx
mkdir c:\dm\lib\directx

Start you browser and Download in c:\sdk

execute 7z920.exe and start win zip. Go, in 7-zip, to c:\sdk

rightclick on w32api-3.17-2-mingw32-src.tar.lzma 7-zip-->extract here
rightclick on w32api-3.17-2-mingw32-src.tar      7-zip-->extract here
rightclick on gawk-3.1.6-1-bin.zip               7-zip-->extract here

goto w32api-3.17-2-mingw32\include

edit windef.h
	around line 120 You see:
	#define DECLSPEC_IMPORT __declspec(dllimport)
	#define DECLSPEC_EXPORT __declspec(dllexport)
	#ifdef __GNUC__
	#define DECLSPEC_NORETURN __declspec(noreturn)
	#define DECLARE_STDCALL_P( type ) __stdcall type
	#elif defined(__WATCOMC__) 
	#define DECLARE_STDCALL_P( type ) type __stdcall

	change the elif line( around 125) to:
	#elif defined(__WATCOMC__) || defined(__DMC__)
and save.

in command.com window do
cd \dm

in 7-zip:
copy the whole include directory to c:\dm\

save the awk program below to c:\sdk\def.awk
$1 ~ /LIBRARY/ { lib = gensub(/['"]/,"","g",$2)
/EXPORTS/ {next}
/^;/{next }
/^[ 	]*$/{next }

$2 ~ /DATA/{next}
{function_name[i++] = $1 }
	print "LIBRARY '" lib "'"
	print "EXETYPE NT"
	print "EXPORTS"
	for(k =0; k < i ;k++){
		number_of_parts = split(function_name[k],parts," ")
		if( 2 == number_of_parts){
			print "_" parts[1] " " parts[2] " = " parts[1]
		}else if (1 == number_of_parts){
			print parts[1]
		}else {
		print "Odd this function has 0 or 3 or more parts " function_name[k]

cd \sdk\w32api-3.17-2-mingw32\lib
for %i in (*.def) do \sdk\bin\awk.exe -f \sdk\def.awk %i > \dm\def\%i

cd ddk
for %i in (*.def) do \sdk\bin\awk.exe -f \sdk\def.awk %i > \dm\def\ddk\%i
cd ..\directx
for %i in (*.def) do \sdk\bin\awk.exe -f \sdk\def.awk %i > \dm\def\directx\%i

cd \dm\def

for %i in (*.def) do \dm\bin\implib.exe /noi \dm\lib\%~ni.lib %i
cd ddk
for %i in (*.def) do \dm\bin\implib.exe /noi \dm\lib\ddk\%~ni.lib %i
cd ..\directx
for %i in (*.def) do \dm\bin\implib.exe /noi \dm\lib\directx\%~ni.lib %i

cd \sdk\w32api-3.17-2-mingw32\lib
for %i in (*uuid.c) do \dm\bin\dmc -c %i
dir /B  *uuid.obj >uuid-lib.bat

edit uuid-lib.bat.
put at the begin \dm\bin\lib -c uuid.lib
and put all the object filenames behind it
write and quit

copy uuid.lib \dm\lib\

\dm\bin\dmc -c shell32.c  gdiplus.c
\dm\bin\lib \dm\lib\shell32.lib shell32.obj
\dm\bin\lib \dm\lib\gdiplus.lib gdiplus.obj

I'm not sure how important the other c files are!

and that should do it! You can  now remove c:\sdk
Mar 18 2012