Developing 32-bit Windows programs
Developing for Stony Brook Ada95 allows you to take advantageof all of Win32 capabilities, including:
Win32 Development Information
Exception Handlers on Exports
Procedures which are marked with the EXPORT attribute will automaticallygenerate an exception handler if you do not supply one. The exception handlerwill terminate the program if it is activated. This is to avoid the situationof an exception propagating to other programs. We strongly recommend that youprovide an explicit exception handler on all exported procedures and handle any exceptionsin a way that best suits your program (Returning an error code for example).
A compiler directive is supplied to allow a procedure with theEXPORT attribute to propagate and exception. This should only be used when Ada95is calling Ada95 code and all of the code is using the same instance of the runtimesystem. If your exported procedure is in a DLL then you should be linking to theDLL version of the Ada95 runtime library for all DLLs and programs.
The information that Win32 provides when an application is runor attached/detached is made available by the following six variables which existin WINX. For information on their usage please consult your Win32 referencemanuals.
Instance : HINSTANCE;
PrevInstance : HINSTANCE;
CmdShow : UINT;
CmdLine : LPSTR;
IsInit : Boolean; -- Initialization or termination. DLL only
IsThread : Boolean; -- Process or Thread. DLL only
The meanings of the last two variables for DLLs are:
WIN32.DLL_PROCESS_ATTACH = WINX.IsInit andthen (NOT WINX.IsThread);
WIN32.DLL_PROCESS_DETACH = (NOT WINX.IsInit)and then (NOT WINX.IsThread);
WIN32.DLL_THREAD_ATTACH = WINX.IsInit andthen WINX.IsThread;
WIN32.DLL_THREAD_DETACH = (NOT WINX.IsInit)and then WINX.IsThread;
For programs IsInit is always True and IsThread is always False.
The main program entry point for normal Ada95 programs is called_SBADAProgramEntry@0. The entry point is external to your code. Your start procedureis called by this external code.
If CMAIN is used the C entry point procedure is the entry point.
For DLLs the entry point is called _SBADADllEntry@12.
To include a resource in a program, put the compiler resourcedirective into your source file. You can have more than one resource file perprogram when using the Stony Brook linker. If you use other linkers this may notbe the case. The environment uses this directive to track a dependency betweenthe source file with the directive and the resource file. The resource file willbe linked when the source file with the directive is a part of the program.
Creating Help Files
Standard Input and Output
A normal Win32 program does not have any standard input of outputhandles unless explicitly given these handles by the program that starts the program.For standard input and output Win32 programs you must make sure that the ConsoleApplication Linker Option is set.