You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A drawback of #399 is that the initialization of parameters which have a pointer type does not work anymore. For instance
target Cpp;
reactor Foo(ptr: int*({=nullptr=})) {
reaction (startup) {=
std::cout << "Got " << *ptr << "\n";
=}
}
main reactor {
private preamble {=
int bar{42};
=}
// don't do this at home
foo = new Foo(ptr={=&bar=});
}
does not compile.
While generally speaking pointers should be avoided, sometimes they are needed and there is no way around it. So we should support the above program and have it compile correctly. However, this does not seem to be easy to solve because of C++'s peculiarities.
For now, this simple workaround can be used:
target Cpp;
reactor Foo(ptr: int_ptr({=nullptr=})) {
public preamble {=
using int_ptr = int*;
=}
reaction (startup) {=
std::cout << "Got " << *ptr << "\n";
=}
}
main reactor {
private preamble {=
int bar{42};
=}
// don't do this at home
foo = new Foo(ptr={=&bar=});
}
The text was updated successfully, but these errors were encountered:
A drawback of #399 is that the initialization of parameters which have a pointer type does not work anymore. For instance
does not compile.
While generally speaking pointers should be avoided, sometimes they are needed and there is no way around it. So we should support the above program and have it compile correctly. However, this does not seem to be easy to solve because of C++'s peculiarities.
For now, this simple workaround can be used:
The text was updated successfully, but these errors were encountered: