Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

FunctionPointer - error: forming pointer to reference type #33

Open
headlessme opened this issue Oct 2, 2015 · 2 comments
Open

FunctionPointer - error: forming pointer to reference type #33

headlessme opened this issue Oct 2, 2015 · 2 comments
Labels

Comments

@headlessme
Copy link

Should FunctionPointer work with reference types as its template arguments?

For example:

typedef mbed::util::FunctionPointer3<void, SomeClass&, uint32_t, SomeOtherClass&> my_function_ptr_t;

used like this:

my_function_ptr_t callback(this, &AwesomeClass::doAwesomeness);
doSomethingWithCallback(callback);

gives an error like:

/yotta_modules/core-util/core-util/FunctionPointer.h:363:9: error: forming pointer to reference type 'SomeOtherClass&'
         arg_struct(const A1 *b1, const A2 *b2, const A3* b3) {
         ^

@bremoran @autopulated

@bremoran
Copy link
Contributor

bremoran commented Oct 5, 2015

The problem here is that function pointer uses pointers to pull arguments through a va_args funciton. I use pointers there because references cannot traverse va_args lists. Unfortunately, this creates a bit of a limitation.

If we use C++11, the use of variadic macros will make it possible to remove this limitation.

@rainierwolfcastle
Copy link

ARM Internal Ref: IOTSFW-977

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants