Move win_examples out into tmp tree
This commit was SVN r3649.
Этот коммит содержится в:
родитель
fa6558db61
Коммит
8d4506a03e
@ -1,15 +0,0 @@
|
||||
#include "hello.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int hello(void);
|
||||
int hell(void);
|
||||
|
||||
hello_t anju = {hello, hell};
|
||||
bool aaa = true;
|
||||
|
||||
static int hello(void) {
|
||||
return printf("Hello World\n");
|
||||
}
|
||||
static int hell(void) {
|
||||
return printf("Hell with you World\n");
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#ifndef HELLO_H
|
||||
#define HELLO_H
|
||||
|
||||
#if !(defined(__cplusplus) || defined(c_plusplus))
|
||||
typedef enum {false, true} bool;
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int (*one_fn)(void);
|
||||
typedef int (*two_fn)(void);
|
||||
|
||||
|
||||
struct hello_t {
|
||||
one_fn i;
|
||||
two_fn j;
|
||||
};
|
||||
typedef struct hello_t hello_t;
|
||||
|
||||
|
||||
#ifdef EXPORTING
|
||||
__declspec(dllexport) extern hello_t anju;
|
||||
__declspec(dllexport) extern bool aaa;
|
||||
#else
|
||||
__declspec(dllimport) extern hello_t anju;
|
||||
__declspec(dllimport) extern bool aaa;
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*HELLO_H*/
|
@ -1,14 +0,0 @@
|
||||
#include "hello.h"
|
||||
#include <stdio.h>
|
||||
|
||||
struct new_anju {
|
||||
hello_t *hell;
|
||||
} ;
|
||||
struct new_anju boo = {&anju};
|
||||
|
||||
int main() {
|
||||
|
||||
boo.hell->i();
|
||||
boo.hell->j();
|
||||
return 0;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
all: hello main
|
||||
|
||||
hello: hello.c hello.h
|
||||
cl /TC /LD /DEXPORTING hello.c
|
||||
|
||||
main: main.cpp
|
||||
cl main.cpp hello.lib
|
||||
|
||||
clean:
|
||||
rm -Rf *.obj *.lib *.dll *.exp *.i *.exe
|
@ -1,29 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "component.h"
|
||||
|
||||
static struct module *component_query(int i);
|
||||
static void module_query(int i);
|
||||
|
||||
|
||||
/* This is the component struct, and is exported */
|
||||
//__declspec(dllexport)
|
||||
__declspec(dllexport) struct component component_instance = {
|
||||
component_query
|
||||
};
|
||||
|
||||
/* This is the module struct, and is static */
|
||||
static struct module module_instance = {
|
||||
module_query
|
||||
};
|
||||
|
||||
static struct module *component_query(int i)
|
||||
{
|
||||
printf("this is the component query: I got value %d\n", i);
|
||||
return &module_instance;
|
||||
}
|
||||
|
||||
static void module_query(int i)
|
||||
{
|
||||
printf("this is the module query: I got value %d\n", i);
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#ifndef COMPONENT_H
|
||||
#define COMPONENT_H
|
||||
|
||||
struct component;
|
||||
struct module;
|
||||
|
||||
typedef struct module *(*component_query_fn_t)(int i);
|
||||
|
||||
struct component {
|
||||
component_query_fn_t component_query_fn;
|
||||
};
|
||||
|
||||
typedef void (*module_query_fn_t)(int i);
|
||||
|
||||
struct module {
|
||||
module_query_fn_t module_query_fn;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
/* Prabhanjan Kambadur: Open Systems Lab
|
||||
Example documenting the usage of functions from a dynamic library in windows
|
||||
September 24 2004 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include "component.h"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
HINSTANCE hinstLib;
|
||||
struct component *component;
|
||||
struct module *module;
|
||||
|
||||
/* Get a handle to the DLL */
|
||||
|
||||
hinstLib = LoadLibrary("component");
|
||||
|
||||
/* If the handle is valid, try to get the function address */
|
||||
|
||||
if (hinstLib != NULL) {
|
||||
component = (struct component *) GetProcAddress(hinstLib,
|
||||
"component_instance");
|
||||
|
||||
/* If the function address is valid, call the function */
|
||||
|
||||
if (NULL != component) {
|
||||
module = component->component_query_fn(37);
|
||||
module->module_query_fn(17);
|
||||
} else {
|
||||
printf("Was not able to find component_instance\n");
|
||||
}
|
||||
} else {
|
||||
printf("Was not able to LoadLibrary\n");
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
all: dll load
|
||||
|
||||
dll: component.c component.h
|
||||
cl /LD component.c
|
||||
|
||||
load: loading.c component.h
|
||||
cl loading.c
|
||||
|
||||
clean:
|
||||
rm -Rf *.dll *.obj core* *.lib *.exp *.exe
|
Загрузка…
Ссылка в новой задаче
Block a user