Mail Archives: djgpp/2000/08/11/22:30:18
Message-ID: | <3994B1F5.32956831@addr.com>
|
From: | Ardy Falls <ardy AT addr DOT com>
|
X-Mailer: | Mozilla 4.74 [en]C-CCK-MCD NSCPCD47 (Win98; U)
|
X-Accept-Language: | en
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | DXE Question
|
Lines: | 57
|
Date: | Fri, 11 Aug 2000 19:09:57 -0700
|
NNTP-Posting-Host: | 63.196.4.119
|
X-Complaints-To: | abuse AT pacbell DOT net
|
X-Trace: | news.pacbell.net 966046284 63.196.4.119 (Fri, 11 Aug 2000 19:11:24 PDT)
|
NNTP-Posting-Date: | Fri, 11 Aug 2000 19:11:24 PDT
|
Organization: | SBC Internet Services
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hi I'm trying to make a dxe function that passes pointers to other
functions within that .o file.
here is the source code
these to files are compiled this way
gxx -o dxetest.exe dxetest.c
gxx -c test.c test.o
dxegen test.dxe _Funct_Init test.o
**************dxetest.c***********
#include <sys/dxe.h>
static int (*add)(int a, int b);
static int (*sub)(int a, int b);
static void *(*Funct_Init)(char *FunctName);
int main(void)
{
printf("loading test.dxe...\n");
Funct_Init = _dxe_load("test.dxe");
if (Funct_Init == 0) {
printf("Cannot load test.dxe\n");
return 1;
}
add=Funct_Init("Add");
sub=Funct_Init("Sub");
if (sub == 0) {
printf("Error in test.dxe\n");
return 1;
}
if (add == 0) {
printf("Error in test.dxe\n");
return 1;
}
printf("Okay, 3 + 4 = %d\n", add(3,4));
printf("Okay, 3 - 4 = %d\n", sub(3,4));
return 0;
}
***************************test.c*************************8
static int add(int a,int b) {
return (a+b);
}
static int sub(int a,int b)
{
return a-b;
}
void *Funct_Init(char *FunctName)
{
if(FunctName=="Add") return((int(*)(int a,int b))add);
if(FunctName=="Sub") return((int(*)(int a,int b))sub);
}
Thnaks a million,
Ardy
http://www.addr.com/~ardy/
- Raw text -