Re: How can a function pointer required to be extern(C)?

2023-04-13 Thread rempas via Digitalmars-d-learn
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,

Re: How can a function pointer required to be extern(C)?

2023-04-13 Thread rempas via Digitalmars-d-learn
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 =

Re: How can a function pointer required to be extern(C)?

2023-04-12 Thread John Chapman via Digitalmars-d-learn
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(); You can also express it like this: ```d extern(C) alias FuncPtr = void* function(void*); ```

Re: How can a function pointer required to be extern(C)?

2023-04-12 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Apr 12, 2023 at 08:23:51PM +, rempas via Digitalmars-d-learn wrote: > Sorry if the title doesn't make any sense, let me explain. So, I do have the > following code that does not compile: > > ```d > import core.sys.posix.pthread; /* The library */ > > struct Thread { > private: >

How can a function pointer required to be extern(C)?

2023-04-12 Thread rempas via Digitalmars-d-learn
Sorry if the title doesn't make any sense, let me explain. So, I do have the following code that does not compile: ```d import core.sys.posix.pthread; /* The library */ struct Thread { private: pthread_t thread_id; public: this(void* function(void*) func, void* arg = null, scope