#ifndef SAMPLE_H
#define	SAMPLE_H

#ifdef _CH_
/*
#pragma package <chsample>
#include <chdl.h>
LOAD_CHDL(sample)
*/
#include <dlfcn.h>
void *_Chsample_handle = dlopen("libsample.dl", RTLD_LAZY);
#pragma exec _Chsample_handle?0:                           \
   fprintf(_stderr, "Error: dlopen(): %s\n", dlerror()), \
   fprintf(_stderr, "       cannot get _Chsample_handle in sample.h\n");
void _dlclose_sample(void) {
   dlclose(_Chsample_handle);
}
atexit(_dlclose_sample);
#endif

/* func1() and func2() use sin() and hypot() in sample.h */
#include <sample.h> 
#include <stdio.h> 

typedef struct tag {int i;
            float f;
} TAG;
typedef int (*FUNPTR)(int n);

extern double func1(double x);
extern double func2(double x, double y);
extern TAG func3(int n);      /* return struct */
extern TAG func4(int n);      /* return struct */
extern int func5(FUNPTR fp, int n);  /* arg is pointer to func */

#endif /* SAMPLE_H */
