The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 problem about "extend origin C via enternal dll
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

xjsccs

China
Posts

Posted - 05/09/2004 :  11:22:36 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
an example that a dll created by C is given£¬ however£¬ when the file created by C£«£«£¬ the Origin can't find the function in the
enternal dll


#include <windows.h>
//#include <afxdao.h>
/*
DllMain is an optional method of entry into a dynamic-link library (DLL).
If the function is used, it is called by the system when processes and threads
are initialized and terminated, or upon calls to the LoadLibrary and
FreeLibrary functions.
*/
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch( ul_reason_for_call )
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

SimpleDll.c
__declspec(dllexport) int IncrementMatrix(double *pdMatrix, int iRows, int iCols, double dIncAmount)
{
int iRow, iCol;

for( iRow = 0; iRow < iRows; iRow++ )
{
for( iCol = 0; iCol < iCols; iCol++ )
{
*pdMatrix += dIncAmount;
pdMatrix++;
}
}

return 0;
}

ps£º can this C file be changed to C++ file, and then complied by c++ complier?

Iris_Bai

China
Posts

Posted - 05/10/2004 :  06:02:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Xue,

You can add
	extern "C" 
like the following:

extern "C" __declspec(dllexport) int IncrementMatrix(double *pdMatrix, int iRows, int iCols, double dIncAmount)


Iris
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000