D
deltaquattro
Hi,
it has been quite some time (heck, 10 years!) since I last wrote some C code, and now I need to write an UDF (user defined function) for a commercial software. The UDF is written in plain C, with only three differences:
1. all the headers of the standard library are included by including the special header udf.h;
2. some prebuilt macros are available, identified by their names in capital letters;
3. a new data type, real, is defined, which the commercial software translates to float or double, depending on the user settings (i.e., whether one runs the software in single or double precision).
Having said that, I would like to know how I define a function in a C source file, so that it can be called by another function in the same file. Specifically, I have:
/*************************************************************************/
/* foo.c */
/*************************************************************************/
#include "udf.h"
#define PI 93.1415926536
real myfun(real x, real y, real t)
{
real theta;
real u0=1.0;
real omega = 2*PI;
real u;
theta = atan2(x,y);
u = u0+sin(omega*t+theta);
return u
}
How do I instruct another function in the same source file to use myfun? Thanks,
Best Regards
deltaquattro
it has been quite some time (heck, 10 years!) since I last wrote some C code, and now I need to write an UDF (user defined function) for a commercial software. The UDF is written in plain C, with only three differences:
1. all the headers of the standard library are included by including the special header udf.h;
2. some prebuilt macros are available, identified by their names in capital letters;
3. a new data type, real, is defined, which the commercial software translates to float or double, depending on the user settings (i.e., whether one runs the software in single or double precision).
Having said that, I would like to know how I define a function in a C source file, so that it can be called by another function in the same file. Specifically, I have:
/*************************************************************************/
/* foo.c */
/*************************************************************************/
#include "udf.h"
#define PI 93.1415926536
real myfun(real x, real y, real t)
{
real theta;
real u0=1.0;
real omega = 2*PI;
real u;
theta = atan2(x,y);
u = u0+sin(omega*t+theta);
return u
}
How do I instruct another function in the same source file to use myfun? Thanks,
Best Regards
deltaquattro