But I want a "structured array". Not just an array of specific type
values.
ie.
#pragma data_seg (".MYSEG")
struct this_array { int v1; double v2; double v3; int v4; double
v5;};
#pragma data_seg()
Does this make sense? How can a "share' a structured array?
PS. I did figure out how to share data in my DLL from an earlier post.
A "collection" of things of different types is not an array. An array
is a collection of things (in C++, generally speaking, objects) of the
same type.
You can pack "objects" of different types in an struct or array,
mostly like you've done:
struct myStruct
{
int v1;
double v2;
double v3;
int v4;
double v5;
};
You can pass this mostly as any other object. And you can do arrays of
such objects too.
By the way, if possible, avoid C-style arrays (int whatever[5]).
Better use collection classes, like std::vector.
Thanks. I think I figured out what I wanted to do:
struct SymbolData{double a; double b; double p; int s; int f;};
#pragma data_seg (".ARB")
SymbolData g_data1={0.0,0.0,0.0,0,0};
SymbolData g_data2={0.0,0.0,0.0,0,0};
#pragma data_seg()
#pragma comment(linker, "/SECTION:.ARB,RWS")
It's 2am where I'm at and I'm getting my terms mixed up. Sorry.
What do you think of the above?
>Ok. I get I can do this:
>#pragma data_seg (".MYSEG")
> int this_array[5];
>#pragma data_seg()
****
First, note that absolutely NOTHING USEFUL happens when you code the above. The
this_array will NOT be in the segment "MYSEG". If, on the other hand, you had written
int this_array[5] = {0};
then it would work; the data_seg is ignored if there is not an initialization clause
****
>
>But I want a "structured array". Not just an array of specific type
>values.
>ie.
>#pragma data_seg (".MYSEG")
> struct this_array { int v1; double v2; double v3; int v4; double
>v5;};
>#pragma data_seg()
****
How could it NOT make sense? It is perfectly valid C, and it works the same as any other
declaration. However, you MUST do an initialization clause if you want it in "MYSEG",
i.e.
struct this_array {int v1; double v2; double v3; int v4; double v5; } = {0};
or it will end up in the default data segment..
What you can't share is a pointer-to-something, e.g., you could not put a char* in (unless
you use based pointers, which is another completely separate discussion)
joe
*****
>
>Does this make sense? How can a "share' a structured array?
>
>PS. I did figure out how to share data in my DLL from an earlier post.
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Well, what I've got coded works.
A valid and more flexible alternative could be Boost.Interprocess
library (a header only library):
http://www.boost.org/doc/libs/1_47_0/doc/html/interprocess.html
Regards
--
Cholo Lennon
Bs.As.
ARG