source: CMT/v1r19/src/demo/demoC/demoC.cxx @ 1

Last change on this file since 1 was 1, checked in by arnault, 19 years ago

Import all tags

File size: 1.3 KB
Line 
1//-----------------------------------------------------------
2// Copyright Christian Arnault LAL-Orsay CNRS
3// arnault@lal.in2p3.fr
4// See the complete license in cmt_license.txt "http://www.cecill.info".
5//-----------------------------------------------------------
6
7#include <stdio.h>
8
9typedef void (*Procedure) ();
10
11#ifdef WIN32
12#include <windows.h>
13
14Procedure get_proc (const char* name)
15{
16  void* f = ::LoadLibrary ("..\\Win32Debug\\C.dll");
17
18  if (f == 0)
19    {
20      f = ::LoadLibrary ("..\\VisualC\\C.dll");
21    }
22
23  if (f == 0)
24    {
25      printf ("Cannot load the library\n");
26      exit (0);
27    }
28
29  Procedure p;
30
31  p = (Procedure)::GetProcAddress ((HMODULE) f, name);
32  if (p == 0)
33    {
34      char* s = new char[strlen(name) + 2];
35      s[0] = '_';
36      strcpy (s+1, name);
37      p = (Procedure)::GetProcAddress((HMODULE) f, s);
38    } 
39
40  if (p == 0)
41    {
42      printf ("Cannot get the module %s\n", name);
43      exit (0);
44    }
45
46  return (p);
47}
48#else
49extern "C" {
50void C1 ();
51void C2 ();
52void C3 ();
53}
54#endif
55
56int main ()
57{
58  printf ("demoC\n");
59
60  Procedure c = 0;
61
62#ifdef WIN32
63  c = get_proc ("C1");
64  c ();
65  c = get_proc ("C2");
66  c ();
67  c = get_proc ("C3");
68  c ();
69#else
70  C1 ();
71  C2 ();
72  C3 ();
73#endif
74
75  return (0);
76}
77
78
79
Note: See TracBrowser for help on using the repository browser.