L
Leslaw Bieniasz
Hi,
In my program I need to have several (global) functions that share some
data, but I want to avoid introducing global data. I am therefore trying
to use the following construct:
inline const long double *const get_data_ptr(void)
{
static const long double data[10]
{
1.0L, 2.0L, 3.0L, etc.
};
return data;
}
void a(void)
{
static const long double *const data = get_data_ptr();
// use the data, for example
long double x = data[0] + data[1];
return;
}
void b(void)
{
static const long double *const data = get_data_ptr();
// use the data, for example
long double y = data[0]*data[1];
return;
}
This compiles without errors, and seems to work
without errors. However, is this construct correct?
If this plays any role, I am using
Borland C++ Builder 6.0.
Leslaw
In my program I need to have several (global) functions that share some
data, but I want to avoid introducing global data. I am therefore trying
to use the following construct:
inline const long double *const get_data_ptr(void)
{
static const long double data[10]
{
1.0L, 2.0L, 3.0L, etc.
};
return data;
}
void a(void)
{
static const long double *const data = get_data_ptr();
// use the data, for example
long double x = data[0] + data[1];
return;
}
void b(void)
{
static const long double *const data = get_data_ptr();
// use the data, for example
long double y = data[0]*data[1];
return;
}
This compiles without errors, and seems to work
without errors. However, is this construct correct?
If this plays any role, I am using
Borland C++ Builder 6.0.
Leslaw