Thread overview |
---|
July 12, 2018 How to define syscall() in freebsd? | ||||
---|---|---|---|---|
| ||||
the code is error: extern (C) nothrow @nogc size_t syscall(size_t ident); extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); long tid; syscall(SYS_thr_self, &tid); writeln(tid); Error: Function type does not match previously declared function with the same mangled name: syscall Change to: extern (C) nothrow @nogc size_t syscall(size_t ident); extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); long tid; syscall(SYS_thr_self, &tid); writeln(tid); Error: none of the overloads of syscall are callable using argument types (int, long*), candidates are: source/app.d(3,33): kiss.sys.syscall.syscall(ulong ident) source/app.d(4,33): kiss.sys.syscall.syscall(ulong ident, ulong arg0) Change to: // extern (C) nothrow @nogc size_t syscall(size_t ident); // extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); long tid; syscall(SYS_thr_self, &tid); writeln(tid); result: 100567 |
July 12, 2018 Re: How to define syscall() in freebsd? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brian | On Thursday, 12 July 2018 at 13:55:58 UTC, Brian wrote: > the code is error: > extern (C) nothrow @nogc size_t syscall(size_t ident); > extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); > extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); > > long tid; > syscall(SYS_thr_self, &tid); > writeln(tid); > > Error: Function type does not match previously declared function with the same mangled name: syscall Just like in C, you cannot declare multiple extern(C) functions with the same name. > Change to: > extern (C) nothrow @nogc size_t syscall(size_t ident); > extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); > extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); > > long tid; > syscall(SYS_thr_self, &tid); > writeln(tid); What did you change? I see no difference. > Error: none of the overloads of syscall are callable using argument types (int, long*), candidates are: > source/app.d(3,33): kiss.sys.syscall.syscall(ulong ident) > source/app.d(4,33): kiss.sys.syscall.syscall(ulong ident, ulong arg0) Look at the types: the error says you're passing an int and long* on 64-bit to functions with different types. > Change to: > // extern (C) nothrow @nogc size_t syscall(size_t ident); > // extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); > extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); > > long tid; > syscall(SYS_thr_self, &tid); > writeln(tid); > > result: > > 100567 Probably related to first issue mentioned- you cannot overload C functions- maybe the compiler finds the third now that you removed the disallowed overloads. |
July 12, 2018 Re: How to define syscall() in freebsd? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joakim | On Thursday, 12 July 2018 at 15:45:41 UTC, Joakim wrote: > On Thursday, 12 July 2018 at 13:55:58 UTC, Brian wrote: >> the code is error: >> extern (C) nothrow @nogc size_t syscall(size_t ident); >> extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); >> extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); >> >> long tid; >> syscall(SYS_thr_self, &tid); >> writeln(tid); >> >> Error: Function type does not match previously declared function with the same mangled name: syscall > > Just like in C, you cannot declare multiple extern(C) functions with the same name. > >> Change to: >> extern (C) nothrow @nogc size_t syscall(size_t ident); >> extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); >> extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); >> >> long tid; >> syscall(SYS_thr_self, &tid); >> writeln(tid); > > What did you change? I see no difference. > >> Error: none of the overloads of syscall are callable using argument types (int, long*), candidates are: >> source/app.d(3,33): kiss.sys.syscall.syscall(ulong ident) >> source/app.d(4,33): kiss.sys.syscall.syscall(ulong ident, ulong arg0) > > Look at the types: the error says you're passing an int and long* on 64-bit to functions with different types. > >> Change to: >> // extern (C) nothrow @nogc size_t syscall(size_t ident); >> // extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); >> extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); >> >> long tid; >> syscall(SYS_thr_self, &tid); >> writeln(tid); >> >> result: >> >> 100567 > > Probably related to first issue mentioned- you cannot overload C functions- maybe the compiler finds the third now that you removed the disallowed overloads. I'm sorry, downstairs: the code is error: extern (C) nothrow @nogc size_t syscall(size_t ident); extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); extern (C) nothrow @nogc size_t syscall(size_t ident, long* arg0); long tid; syscall(SYS_thr_self, &tid); writeln(tid); Error: Function type does not match previously declared function with the same mangled name: syscall Change to: extern (C) nothrow @nogc size_t syscall(size_t ident); extern (C) nothrow @nogc size_t syscall(size_t ident, size_t arg0); long tid; syscall(SYS_thr_self, &tid); writeln(tid); Error: none of the overloads of syscall are callable using argument types (int, long*), candidates are: source/app.d(3,33): kiss.sys.syscall.syscall(ulong ident) source/app.d(4,33): kiss.sys.syscall.syscall(ulong ident, ulong arg0) freebsd syscall() https://www.freebsd.org/cgi/man.cgi?query=syscall&sektion=2 How to define it in D? |
July 13, 2018 Re: How to define syscall() in freebsd? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brian | On Thursday, 12 July 2018 at 20:19:17 UTC, Brian wrote:
>
> freebsd syscall()
> https://www.freebsd.org/cgi/man.cgi?query=syscall&sektion=2
>
> How to define it in D?
It should be fine like this:
extern (C) nothrow @nogc size_t syscall(size_t ident, ...);
|
July 13, 2018 Re: How to define syscall() in freebsd? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Heromyth | On Friday, 13 July 2018 at 02:56:23 UTC, Heromyth wrote: > On Thursday, 12 July 2018 at 20:19:17 UTC, Brian wrote: >> >> freebsd syscall() >> https://www.freebsd.org/cgi/man.cgi?query=syscall&sektion=2 >> >> How to define it in D? > > It should be fine like this: > > extern (C) nothrow @nogc size_t syscall(size_t ident, ...); hahaha, thanks MR zhang! kiss.sys.syscall module is resolved. https://github.com/huntlabs/kiss/blob/master/source/kiss/sys/syscall/package.d |
Copyright © 1999-2021 by the D Language Foundation