I'm hoping to use your work on said subject within a project. I'm glad
to see someone has put so much effort into this problem - a nice feat!
However, when trying to introduce some of the examples from the end of
your paper into my code I'm getting a strange error about external
linkage being needed - even when variables are declared extern!
I'm hoping to use your work on said subject within a project. I'm glad
to see someone has put so much effort into this problem - a nice feat!
However, when trying to introduce some of the examples from the end of
your paper into my code I'm getting a strange error about external
linkage being needed - even when variables are declared extern!
For example:
// alloc.h
#include <shared_memory.h>
#include <pooled_allocator.h>
using mem_space::allocator_key_t;
using mem_space::allocator_addr_t;
using pooled_allocator::Pool_alloc;
extern allocator_key_t key;
extern allocator_addr_t offset;
// class.cpp
#include "class.h"
#include "alloc.h"
myclass::myclass {
extern allocator_key_t key;
extern allocator_addr_t offset;
key = "/clireg.key";
offset = "0x0000D000";
Pool_alloc<pid_t, key, offset> allocator;
}
The above (when of course complete) results in:
myclass.cpp:41: error: `key' is not a valid template argument
myclass.cpp:41: error: it must be the address of an object with external
linkage
When compiled with gcc 3.3.3 on RedHat Fedora Core 2. The options to gcc
(or rather g++) include:
-Wall -ansi -pedantic -O2
I've tried variations on a theme but all result in the same message!
Why? I can't figure this one out!
I hope you can help.
Cheers
Jim Vanns
OK Seems I've found how to resolve this - though it is an odd one.
Replace the allocator_key_t etc. with char[] or const char[]!
Cheers
Jim
Jim,
Yes, that is what is done in the main.cc example code. I think that approach is required by the const template parameters,
Marc