Click here to Skip to main content
15,896,063 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 159K   2.3K   86  
If you want to write platform independent code, just read through the following article.
//Boby Thomas - march 2006
// plat_ind.cpp : Definiert den Einstiegspunkt f�r die Konsolenanwendung.
//


#include "os_call.h"

#include <iostream>
using namespace std;

typedef int (*AddFnPtr)(int,int);

int main(int argc, char* argv[])
{
	AddFnPtr AddFn;
	void *hDLL;
	//do not add extension. It is hndled by LoadSharedLibrary.
	hDLL = LoadSharedLibrary("add");

	if(hDLL == 0)
		return 1;
	AddFn = (AddFnPtr)GetFunction(hDLL,"fnAdd");
	int iTmp = AddFn(8,5);
	cout<<"8 + 5 = "<<iTmp;
	FreeSharedLibrary(hDLL);
	return 0;
}

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