Click here to Skip to main content
15,880,608 members
Articles / Operating Systems / Windows

Platform Independent Coding - DLLs and SOs

Rate me:
Please Sign up or sign in to vote.
4.79/5 (86 votes)
28 Mar 2007CPOL9 min read 157.4K   2.3K   86  
If you want to write platform independent code, just read through the following article.
// Boby Thomas Pazheparampil
// 24-02-1981
// add.cpp : Defines the entry point for the DLL application.
//

//#include "stdafx.h"
#include "add.h"

#if defined(_MSC_VER)
	bool APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
				 )
#elif defined(__GNUC__)
	 bool DllMain( void * hModule, 
                       unsigned long  ul_reason_for_call, 
                       void *lpReserved
				 )

#endif // GNU compiler

{
    switch (ul_reason_for_call)
	{
		case 1://DLL_PROCESS_ATTACH:
		case 2:// DLL_THREAD_ATTACH:
		case 3://DLL_THREAD_DETACH:
		case 0://DLL_PROCESS_DETACH:
			break;
    }
    return true;
}


// This is an example of an exported function.
extern "C" ADD_API int fnAdd(int a, int b)
{
	return (a+b);
}
   

// see add.h for the class definition
CAdd::CAdd()
{ 
	return; 
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) DWS
Australia Australia

Comments and Discussions