F
flowstudioLA
I have a template class object that I use as a mesaging queue between
threads. I use it as a static object that I initialize like so:
foo.h
class foo{
static LFQueue<const char*,100> lfqMyQueue;
};
foo.cpp
LFQueue<const char*,100> Foo::lfqMyQueue;
This has worked fine for me. The problems that I've run into is when
I've attempted to get tricky and try and declare a number of LFQueue
objects in a static array, so that I can access a number of queues out
of a single object. I tried to do it like so:
foo.h
class foo{
static LFQueue<const char*,100> aLFQArray[3];
};
foo.cpp
LFQueue<const char*,100> Foo::aLFQArray[3];
This compiles ok, but when I use it, the const char data goes out of
scope and I get garbage when trying to read from the queue. I'm not
sure if I failed to set it up right, or if the way the queue template
class is setup makes this impossible. It's almost like the array is
static, but the LFQueue elements are not?
Anyway, if any of you could shed some light on how I could go about
this given what you see above, that would be great. If you need more
info I can post the LFQueue Template class code, but I wanted to make
sure it wasn't something obvious with the way this was being declared.
Many thanks!
Haley
threads. I use it as a static object that I initialize like so:
foo.h
class foo{
static LFQueue<const char*,100> lfqMyQueue;
};
foo.cpp
LFQueue<const char*,100> Foo::lfqMyQueue;
This has worked fine for me. The problems that I've run into is when
I've attempted to get tricky and try and declare a number of LFQueue
objects in a static array, so that I can access a number of queues out
of a single object. I tried to do it like so:
foo.h
class foo{
static LFQueue<const char*,100> aLFQArray[3];
};
foo.cpp
LFQueue<const char*,100> Foo::aLFQArray[3];
This compiles ok, but when I use it, the const char data goes out of
scope and I get garbage when trying to read from the queue. I'm not
sure if I failed to set it up right, or if the way the queue template
class is setup makes this impossible. It's almost like the array is
static, but the LFQueue elements are not?
Anyway, if any of you could shed some light on how I could go about
this given what you see above, that would be great. If you need more
info I can post the LFQueue Template class code, but I wanted to make
sure it wasn't something obvious with the way this was being declared.
Many thanks!
Haley