Vino
```
To get a function pointer type from a function type, you can
add `*` on the end:
void func(int) {}
alias FuncType = typeof(func);
pragma(msg, FuncType); // void(int)
alias FuncPtrType = FuncType*;
pragma(msg, FuncPtrType); // void function(int)
static asser
On Wednesday, 30 August 2023 at 17:48:19 UTC, Vino wrote:
Hi All,
Request your help on hot to create a pointer for a function
whose function type is Result.
```
ReturnType!(typeof(&test)).stringof; // Result
From
Vino
```
To get a function pointer type from a function type, you can
On Wednesday, 12 April 2023 at 21:00:04 UTC, John Chapman wrote:
You can also express it like this:
```d
extern(C) alias FuncPtr = void* function(void*);
```
Thank you! This is how I was planning to do anyway because other
that the fact that I like the syntax of that a little bit more,
this
On Wednesday, 12 April 2023 at 20:36:59 UTC, H. S. Teoh wrote:
IMO this is a bug either in D's syntax or in the parser. I'd
file an enhancement request.
In the meantime, you can use alias as a workaround:
---snip---
extern(C) void* abc(void*) {return null;}
alias FuncPtr = typeof(
On Wednesday, 12 April 2023 at 20:36:59 UTC, H. S. Teoh wrote:
---snip---
extern(C) void* abc(void*) {return null;}
alias FuncPtr = typeof(&abc);
You can also express it like this:
```d
extern(C) alias FuncPtr = void* function(void*);
```
{ return this.thread_id; }
> }
>
> ```
>
> Yes, I'm trying to "encapsulate" the Pthread (POSIX threads) API.
> Normally, the function pointer that is passed to "pthread_create" must
> be "extern(C)" and this is the complaining that the compile d
const(pthread_attr_t*) attr = null) {
pthread_create(&this.thread_id, attr, func, arg);
}
@property:
pthread_t id() { return this.thread_id; }
}
```
Yes, I'm trying to "encapsulate" the Pthread (POSIX threads) API.
Normally, the function pointer that is passed to &
, and because it
allows the remaining ScopeCleanup struct to be more general
purpose, for non-C functions, and for functions that don't return
void but an error code which I want to discard.)
The first problem was indeed that a C function pointer "is not" a
D one. So annotati
On 22.11.22 22:11, XavierAP wrote:
I was surprised when it didn't compile, though I immediately found it
understandable...
Already read through https://dlang.org/spec/interfaceToC.html
and https://wiki.dlang.org/Bind_D_to_C
Is it really the case (that an extern(C) function pointer cann
On Tuesday, 22 November 2022 at 21:11:37 UTC, XavierAP wrote:
I was surprised when it didn't compile, though I immediately
found it understandable...
Already read through https://dlang.org/spec/interfaceToC.html
and https://wiki.dlang.org/Bind_D_to_C
[...]
You need to create an alias contain
I was surprised when it didn't compile, though I immediately
found it understandable...
Already read through https://dlang.org/spec/interfaceToC.html
and https://wiki.dlang.org/Bind_D_to_C
Is it really the case (that an extern(C) function pointer cannot
be assigned to a D variable)? Or is
On Friday, 31 December 2021 at 12:36:46 UTC, H. S. Teoh wrote:
```
void lyr(alias Fn)(ref R r)
{
Fn(r);
}
```
Thanks! That helped me reinvent the engine.
On Fri, Dec 31, 2021 at 11:52:21AM +, kdevel via Digitalmars-d-learn wrote:
[...]
> That is what I want to do. The function template lyr shall be
> (explicitly) instantiated in order to put the resulting function
> pointer into an AA. The call signature of lyr!(foo) and foo must be
&
function
pointer into an AA. The call signature of lyr!(foo) and foo must
be the same.
In C++ this looks like this:
```C++
struct R {
};
// typedef void (* Fn) (R &); // ptr version
typedef void (& Fn) (R &);
template
static void lyr (R &r)
{
// invoke f
}
static void foo (R
On Friday, 31 December 2021 at 03:02:08 UTC, Tejas wrote:
[...]
Is it okay to use template parameter instead of **template
value** parameter?
```d
class R {
}
void foo (R r)
{
}
void lyr (fp_type, R) (fp_type fp, R r)
{
}
pragma (msg, typeof (&foo));
R r;
void main(){
auto foo_ptr = &foo;
Pointers are runtime entities and are not suitable template
parameters (compile time).
So assuming that you are trying to either pass a function
constant of a specific type signature as a template argument, or
a function pointer as an argument with either a template
specialisation or co
On Friday, 31 December 2021 at 00:57:26 UTC, kdevel wrote:
```dptr.d
class R {
}
void foo (R r)
{
}
alias fn = void function (R);
void lyr (fn F) (R r)
{
}
immutable fn foo_ptr = &foo; // line 14
pragma (msg, typeof (foo_ptr));
auto ptr = lyr!(foo_ptr);// line 17
```
dmd reports:
```
im
```dptr.d
class R {
}
void foo (R r)
{
}
alias fn = void function (R);
void lyr (fn F) (R r)
{
}
immutable fn foo_ptr = &foo; // line 14
pragma (msg, typeof (foo_ptr));
auto ptr = lyr!(foo_ptr);// line 17
```
dmd reports:
```
immutable(void function(R))
dptr.d(14): Error: expression `& f
On Sunday, 17 October 2021 at 23:07:15 UTC, Elmar wrote:
Do you have a link for more information how to initialize the D
runtime?
Export a function that calls this:
http://druntime.dpldocs.info/core.runtime.Runtime.initialize.html
And also export a function that calls this:
http://druntime.dpl
On Sunday, 10 October 2021 at 17:14:30 UTC, Adam Ruppe wrote:
On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote:
The language subset "BetterC" is required for calling D
functions from C though.
This is false.
You can use any D features when calling it from C, you just
need to provide a
On 10/10/21 6:44 AM, rempas wrote:
I'm having the following C code:
```
static void* (*ppmalloc)(size_t) = malloc;
static void (*ppfree)(void*) = free;
```
I want to covert this code in D so I try to do the following:
```
static void* function(size_t)*ppmalloc = malloc;
static void function(v
On Sunday, 10 October 2021 at 14:00:37 UTC, Elmar wrote:
On Sunday, 10 October 2021 at 13:56:06 UTC, rempas wrote:
Actually I know about BetterC and how to call C functions from
D and visa versa. I would also disagree that "BetterC" is
almost no improvement over C as about 90% of the language
On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote:
The language subset "BetterC" is required for calling D
functions from C though.
This is false.
You can use any D features when calling it from C, you just need
to provide an init and term function that is called from C that
runtime in
On Sunday, 10 October 2021 at 13:56:06 UTC, rempas wrote:
Actually I know about BetterC and how to call C functions from
D and visa versa. I would also disagree that "BetterC" is
almost no improvement over C as about 90% of the language is
there!! C++ classes are also supported
Nice :-) , y
On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote:
The language subset "BetterC" is required for calling D
functions from C though. Unfortunately, the runtime features of
BetterC are limited and some of C's language features aren't
availabe like C99 variable-length-arrays. "BetterC" is
On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote:
Hopefully it will :-) .
D has some good C support. You can call any C function from `D`
by declaring it `extern(C) `.
The language subset "BetterC" is required for calling D
functions from C though. Unfortunately, the runtime features
On Sunday, 10 October 2021 at 13:10:27 UTC, rempas wrote:
Thanks, I'm converting a library from C to D so I have to fix
all the other bugs first to see If it's working but probably it
will. Have an amazing day my friend!
Hopefully it will :-) .
D has some good C support. You can call any C
On Sunday, 10 October 2021 at 11:26:18 UTC, Elmar wrote:
Hello rempas.
This is the way:
```d
import core.stdc.stdlib : malloc, free;
extern(C) void* function(ulong) mallocPointer = &malloc;
extern(C) void function(void*) freePointer = &free;
```
`function` in the type is already a
oc, free;
extern(C) void* function(ulong) mallocPointer = &malloc;
extern(C) void function(void*) freePointer = &free;
```
`function` in the type is already a function pointer. Not
immediately obvious though: You also must annotate the type with
`extern(C)` otherwise it will not work.
I'm having the following C code:
```
static void* (*ppmalloc)(size_t) = malloc;
static void (*ppfree)(void*) = free;
```
I want to covert this code in D so I try to do the following:
```
static void* function(size_t)*ppmalloc = malloc;
static void function(void*)*ppfree = free;
```
If I do th
I will wait with this code.
WaitForSingleObject(threading, INFINITE);
On Thursday, 19 November 2020 at 15:51:09 UTC, Kagamin wrote:
The delegate is stored on the stack of the calling thread, the
created thread loads it from there, but the calling thread
doesn't wait for that and clobbers the stack right away. If you
were lucky your code would crash.
The thread
The delegate is stored on the stack of the calling thread, the
created thread loads it from there, but the calling thread
doesn't wait for that and clobbers the stack right away. If you
were lucky your code would crash.
Solved replacing this line:
CreateThread(null, 0, &_fun, &fun, 0, null);
to this code:
task!({CreateThread(null, 0, &_fun, &fun, 0,
null);}).executeInNewThread();
))(); // Do not show "Hello
World!" :(
return 0;
}
CreateThread(null, 0, &_fun, &fun, 0, null);
} catch(Throwable){}
}
void main(){
null.threadingw({writeln("Hello World!");});
}
A delegate
// Function threadingw()
void threadingw(HWND hwn, void delegate() fun) nothrow {
try {
// Function _fun()
extern(Windows)
uint _fun(void * arg){
(*(cast(void delegate()*) arg))(); // Do not show "Hello
World!" :(
On 10/27/2018 09:16 PM, learnfirst1 wrote:
I plan to use function pointer least significant bit to store some
information.
If there is no GC on my system, I think it will help the memory is well
aligned.
The question is all the function least significant bit is zero ?
Most definitely
I plan to use function pointer least significant bit to store
some information.
If there is no GC on my system, I think it will help the memory
is well aligned.
The question is all the function least significant bit is zero ?
On Monday, April 09, 2018 00:25:08 solidstate1991 via Digitalmars-d-learn
wrote:
> Would the if(!(myFunctionPointer is null)){} work is I
> intended?
You can also do
if(myFunctionPointer !is null)
- Jonathan M Davis
On Monday, 9 April 2018 at 00:25:08 UTC, solidstate1991 wrote:
Would the if(!(myFunctionPointer is null)){} work is I
intended?
Yes, that works as you expect
https://run.dlang.io/is/ZTtm0P
Would the if(!(myFunctionPointer is null)){} work is I
intended?
On 07/10/2017 05:26 AM, SauceKode wrote:
> I need to pass a group of (C) function pointers to another language from
> D... is there a way to derrive a name from a function pointer? Or do I
> have to manually list out the names?
libunwind should be able to provide that functionality.
I need to pass a group of (C) function pointers to another
language from D... is there a way to derrive a name from a
function pointer? Or do I have to manually list out the names?
Thanks also to Paolo Invernizzi and ag0aep6g for answering with a
similar response. Using Mike's response as it has extra detail.
On Wed, 2017-06-07 at 20:00 +0200, Mike Wey via Digitalmars-d-learn
wrote:
> On 06/07/2017 06:50 PM, Russel Winder via Digitalmars-d-learn wrote:
> > So why isn't &chec
On 06/07/2017 06:50 PM, Russel Winder via Digitalmars-d-learn wrote:
So why isn't &checkFrontend a thing of type check_frontend_t*
AFAIK, you would usually translate:
typedef int (check_frontend_t*)(void *args, struct dvb_v5_fe_parms *parms);
into:
alias check_frontend_t = extern(C) int fun
On 06/07/2017 06:50 PM, Russel Winder via Digitalmars-d-learn wrote:
So why isn't &checkFrontend a thing of type check_frontend_t*?
It's a thing of type `check_frontend_t`, which is a function pointer
already. When you add an asterisk, you get a pointer to a function pointer.
On Wednesday, 7 June 2017 at 16:50:26 UTC, Russel Winder wrote:
In the constructor of an object to abstract the result of a
call to the C library code, the parameter is:
check_frontend_t* cf
You should remove the pointer here...
/Paolo
OK, so I have narrowed down my SIGSEGV problem to having no real idea
how to do C function pointers in D code.
So I have a callback function that will be called from C library code.
It currently has signature:
extern(C) int checkFrontend(void* _arguments, dvb_v5_fe_parms*
frontendParameters)
On Wednesday, 26 April 2017 at 08:24:08 UTC, Basile B. wrote:
On Tuesday, 25 April 2017 at 18:58:58 UTC, Ali Çehreli wrote:
On 04/25/2017 11:54 AM, Ali Çehreli wrote:
My analysis is wrong because that writefln() is for the
bar(float) overload but I still think what you want is
achieved.
Ali
On Tuesday, 25 April 2017 at 18:58:58 UTC, Ali Çehreli wrote:
On 04/25/2017 11:54 AM, Ali Çehreli wrote:
My analysis is wrong because that writefln() is for the
bar(float) overload but I still think what you want is achieved.
Ali
No it's ok, it works. The additional indirection is well avoid
On 04/25/2017 11:54 AM, Ali Çehreli wrote:
> _Dmain:
> pushRBP
> movRBP,RSP
> subRSP,010h
> movRAX,_D6deneme4funcFifZv@GOTPCREL[RIP]
> mov-010h[RBP],RAX
> movssXMM0,FLAT:.rodata[00h][RIP]
> movss-8[RBP],XMM0
>
On 04/25/2017 11:28 AM, ParticlePeter wrote:
> On Tuesday, 25 April 2017 at 16:27:43 UTC, Basile B. wrote:
>> with pragma(inline, true), the function body should be injected at the
>> call sites.
>
> This would not help I fear, the body of the function pointer is unknown
&g
hat I would like to avoid,
the additional indirection to call the function pointer with
the original argument count.
Oops, i can believe i didn't read the last part of your
question.
Do you have any idea about the likelihood of the compiler
removing this indirection as an optimizations?
w
l the function pointer with
the original argument count.
Oops, i can believe i didn't read the last part of your question.
Do you have any idea about the likelihood of the compiler
removing this indirection as an optimizations?
with pragma(inline, true), the function body should be inject
on to call the function pointer with the
original argument count.
Do you have any idea about the likelihood of the compiler
removing this indirection as an optimizations?
On Monday, 24 April 2017 at 16:46:21 UTC, ParticlePeter wrote:
I would like to have this kind of struct:
struct Foo {
private int i;
void function( int i, float f ) bar; // will be defined at
runtime
void bar( float f ) {
bar( i, f );
}
}
[...]
How else can I get the required beh
I would like to have this kind of struct:
struct Foo {
private int i;
void function( int i, float f ) bar; // will be defined at
runtime
void bar( float f ) {
bar( i, f );
}
}
But apparently the function pointer and the member function
cannot have the same name: Error: function
On Tuesday, 14 March 2017 at 19:14:34 UTC, H. S. Teoh wrote:
On Tue, Mar 14, 2017 at 06:59:58PM +, Inquie via
Digitalmars-d-learn wrote:
[...]
[...]
> [...]
[...]
[...]
[...]
Keep in mind, though, that the above creates a function pointer
with the same signature as the mem
) membptr;
> > pragma(msg, typeof(membptr)); // prints `int function(float x)`
> >
> > If you need to refer to the function pointer type frequently, you
> > could alias it to something easier to type;
> >
> > alias FuncPtr = typeof(&X.method);
> >
function that could use any types.
Is there any pitfalls like there are in C++ from generating a
function pointer from them?
e.g.,
X foo(A,B,C) @R @S @T -> X function(A,B,C) @R @S @T fooptr;
In my case, there are no attributes, so that might ease the
burden.
e.g., a template that convert
re any pitfalls like there are in C++ from generating a function
> pointer from them?
>
> e.g.,
>
> X foo(A,B,C) @R @S @T -> X function(A,B,C) @R @S @T fooptr;
>
> In my case, there are no attributes, so that might ease the burden.
>
> e.g., a templat
I am generating member function pointers using the declaration
specified from a standard member function. The standard member
function is a valid D function that could use any types.
Is there any pitfalls like there are in C++ from generating a
function pointer from them?
e.g.,
X foo(A,B,C
On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote:
Z add(Z...)(Z a...) {
return a + b;
}
func[] operatorPool = [&add!int];
Variant library isn't liking that. Removing & causes another
error.
Essentially I want a pool of all operators that I define, but
these operators
On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote:
Z add(Z...)(Z a...) {
return a + b;
}
func[] operatorPool = [&add!int];
Variant library isn't liking that. Removing & causes another
error.
Essentially I want a pool of all operators that I define, but
these operators
Z add(Z...)(Z a...) {
return a + b;
}
func[] operatorPool = [&add!int];
Variant library isn't liking that. Removing & causes another
error.
Essentially I want a pool of all operators that I define, but
these operators can be of differing types (which I should be able
to programatic
On Saturday, 17 December 2016 at 15:15:26 UTC, data pulverizer
wrote:
Does this mean that you can translate C code to D natively? I
am currently only aware of the dstep package.
It may not help you, but something I've done in the past is use
Swig to create a Common Lisp interface. It transla
p.s.: that means that i didn't really *decoded* that declaration,
just brute-forced someting that c++ compiler happily accepts. so
take it with a grain of salt. ;-)
fed to C(++)
compiler and translate to D.
p.s. I confirmed your interpretation on stackoverflow:
http://stackoverflow.com/questions/8722817/syntax-for-a-pointer-to-a-function-returning-a-function-pointer-in-c
On Saturday, 17 December 2016 at 15:15:26 UTC, data pulverizer
wrote:
Does this mean that you can translate C code to D natively? I
am currently only aware of the dstep package.
with my head and bare hands. well, armed with some regular
expressions. did you seen some of my "port" announcemen
char *zSymbol);
...
}
Thanks ketmar,
I guess that this means I got it the other way round the function
pointer that is returned is the function that takes in and
returns void.
at least that is what i managed to decode, fed to C(++)
compiler and translate to D.
Does this mean that you can
On Saturday, 17 December 2016 at 13:39:27 UTC, data pulverizer
wrote:
that is what it means, in D:
//void (*(*xDlSym)(sqlite3_vfs*,void*, const char
*zSymbol))(void);
struct sqlite3_vfs {}
extern(C) {
alias RetRes = void function ();
alias DeclType = RetRes function (sqlite3_vfs *a,void *b,
I have come across a function pointer in C that I am attempting
to convert, and am not sure what the current interpretation is:
```
\\ The C Code:
void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
```
The best I can tell is that this is a function pointer that
returns a
On Friday, 19 February 2016 at 22:34:48 UTC, Chris Wright wrote:
I tested this a fair bit today, and I haven't been able to do
any of the nefarious things I expected to be able to do. No
overwriting variables in the caller's scope, no smashing stack
pointers, etc.
I was surprised by this re
On Fri, 19 Feb 2016 21:57:46 +, Yuxuan Shui wrote:
> I don't think it's safe to convert between function pointer with
> different number of arguments... It's possible to mess up the stack
> frame.
I tested this a fair bit today, and I haven't been able to do a
On Friday, 19 February 2016 at 22:07:25 UTC, Chris Wright wrote:
If you want to cast function pointers successfully, you have to
know the D calling convention.
[snip]
I figured there was an explanation. Definitely "here be dragons"
territory. I hope I can figure out a better solution, but
On Fri, 19 Feb 2016 20:45:23 +, jmh530 wrote:
> I tried to use a cast (below) to modify the function pointer, but it is
> printing the second number instead of the first. I find this behavior
> strange...
If you want to cast function pointers successfully, you have to know the
int y).
I don't think I had looked at what you had done carefully
enough. Basically, you just define a new function and take a
function pointer of that. That might be a brute force solution.
I tried to use a cast (below) to modify the function pointer,
but it is printing the second number
carefully enough.
Basically, you just define a new function and take a function
pointer of that. That might be a brute force solution.
I tried to use a cast (below) to modify the function pointer, but
it is printing the second number instead of the first. I find
this behavior strange...
int
On Friday, 19 February 2016 at 14:21:26 UTC, Kagamin wrote:
int bar(int x)
{
return x;
}
int baz(int x, int y)
{
return bar(x);
}
void main()
{
import std.stdio : writeln;
int function(int x, int y) foo_bar = &baz;
writeln(foo_bar(1, 2));
}
T
On Friday, 19 February 2016 at 11:26:56 UTC, Nicholas Wilson
wrote:
Like
alias fp1 = int function(int x);
alias fp2 = int function(int x, int y);
auto foo(T)(T f)
{
static if (is(T == fp2))
return f;
else static if (is(T == fp1))
{
return
On Friday, 19 February 2016 at 05:41:01 UTC, jmh530 wrote:
void main()
{
import std.stdio : writeln;
auto foo_bar = foo(&bar);
writeln(qux(1, 2, foo_bar)); //compiler error
writeln(qux(1, 2, &baz));
}
int bar(int x)
{
return x;
}
int baz(int x,
On Friday, 19 February 2016 at 05:41:01 UTC, jmh530 wrote:
I'm trying to write a function that will adjust the parameters
of a function pointer.
I think the problem is that it defaults to a delegate not that it
cannot be one
does clarifying this to the compiler work
Like
alias fp1
I'm trying to write a function that will adjust the parameters of
a function pointer.
In the code below, my goal is to call the function qux with a
variety of different function pointers (in the actual
application, I don't have the ability to modify qux). I created a
function
On Friday, 17 July 2015 at 15:49:46 UTC, Roland Hadinger wrote:
On Friday, 17 July 2015 at 15:47:39 UTC, Roland Hadinger wrote:
Otherwise, I'd use templates and an alias. Maybe this will
result in faster code:
bool opIndexAssign(bool value, size_t[2] inds)
{
void impl(bool b)(s
On Thursday, 16 July 2015 at 03:24:54 UTC, Matthew Gamble wrote:
This member function of my struct uses a function pointer btx.
When the line declaring the function pointer is present I get a
LNK2019 error: unresolved external symbol.
Just guessing, probably because bts and btr are intrinsics
On Friday, 17 July 2015 at 15:47:39 UTC, Roland Hadinger wrote:
Otherwise, I'd use templates and an alias. Maybe this will
result in faster code:
bool opIndexAssign(bool value, size_t[2] inds)
{
void impl(bool b)(size_t[2] inds)
{
static if(b)
This member function of my struct uses a function pointer btx.
When the line declaring the function pointer is present I get a
LNK2019 error: unresolved external symbol.
bool opIndexAssign(bool value, size_t[2] inds)
{
int function(size_t*, size_t) btx = (value) ? &bts : &btr; //
On Sat, 11 Jul 2015 11:37:03 +, Tofu Ninja wrote:
>> void function() nothrow pure @nogc @safe [2]arrayName;
>>
>> is perfectly fine too.
>
> Ahh, guess that makes sense, I kept trying to put the [] over near
> function()...
attributes are the parts of the type. and the rule is really simpl
On Saturday, 11 July 2015 at 10:54:45 UTC, ketmar wrote:
On Sat, 11 Jul 2015 09:54:40 +, tcak wrote:
On Saturday, 11 July 2015 at 09:30:43 UTC, Tofu Ninja wrote:
So simple syntax question, how do I make an array slice of
function pointers?
I just have no idea where to put the [] on somet
On Sat, 11 Jul 2015 09:54:40 +, tcak wrote:
> On Saturday, 11 July 2015 at 09:30:43 UTC, Tofu Ninja wrote:
>> So simple syntax question, how do I make an array slice of function
>> pointers?
>>
>> I just have no idea where to put the [] on something like
>>
>> void function() nothrow pure
On Saturday, 11 July 2015 at 09:30:43 UTC, Tofu Ninja wrote:
So simple syntax question, how do I make an array slice of
function pointers?
I just have no idea where to put the [] on something like
void function() nothrow pure @nogc @safe arrayName;
Or should I just alias it and make an a
So simple syntax question, how do I make an array slice of
function pointers?
I just have no idea where to put the [] on something like
void function() nothrow pure @nogc @safe arrayName;
Or should I just alias it and make an array of the alias?
alias f = void function() nothrow pur
On Saturday, 11 April 2015 at 19:08:50 UTC, Marco Leise wrote:
Am Sat, 11 Apr 2015 18:28:35 +
schrieb "Paul D Anderson" :
Is there a way to return the name of a function (a string)
from a pointer to that function?
Function pointer example from D Reference:
---
int function()
Paul D Anderson:
Is there a way to return the name of a function (a string) from
a pointer to that function?
Perhaps creating a string[void*] AA and initializing with all the
function pointers you care about.
Bye,
bearophile
Am Sat, 11 Apr 2015 18:28:35 +
schrieb "Paul D Anderson" :
> Is there a way to return the name of a function (a string) from a
> pointer to that function?
>
> Function pointer example from D Reference:
> ---
> int function() fp;
>
> void test()
> {
&
Is there a way to return the name of a function (a string) from a
pointer to that function?
Function pointer example from D Reference:
---
int function() fp;
void test()
{
static int a = 7;
static int foo() { return a + 3; }
fp = &foo;
}
void bar()
{
test();
int i
On Thursday, 17 October 2013 at 03:21:38 UTC, Chris Cain wrote:
On Thursday, 17 October 2013 at 01:17:21 UTC, TheFlyingFiddle
wrote:
I would like to get access to a member function pointer. Taking
the this* as
the first argument.
...snip...
How should i implement getFP above? Is it even
On Thursday, 17 October 2013 at 01:17:21 UTC, TheFlyingFiddle
wrote:
I would like to get access to a member function pointer. Taking
the this* as
the first argument.
...snip...
How should i implement getFP above? Is it even possible?
Well, it's certainly possible. If you were to do
I would like to get access to a member function pointer. Taking
the this* as
the first argument.
class Foo
{
void bar(int a)
{
//do something awesome
}
}
unittest
{
Foo a = new Foo();
Foo b = new Foo();
auto fp = getFP!(Foo.bar);
fp(a, 1); //Basically calls
Am 13.10.2013 17:17, schrieb Artur Skawina:
On 10/13/13 16:43, Benjamin Thaut wrote:
Am 10.10.2013 17:45, schrieb Namespace:
On Thursday, 10 October 2013 at 15:15:45 UTC, bearophile wrote:
Namespace:
You mean like this?
void foo(T)(extern(C) void function(T*) func) {
}
That print
1 - 100 of 167 matches
Mail list logo