static init c struct with array filed

2022-03-16 Thread test via Digitalmars-d-learn
```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not change the type def). I am not sure how to do it in D.

Re: question about bitfields to decode websocket header

2018-11-07 Thread test via Digitalmars-d-learn
On Wednesday, 7 November 2018 at 14:22:43 UTC, lithium iodate wrote: On Wednesday, 7 November 2018 at 13:05:49 UTC, test wrote: I am confused about the bitfields order. The bitfields start with the least significant bits: fin -> 1 rsv1 -> 0 rsv2 -> 0 rsv3 -> 0 opcode -> 1000 = 8 mask -> 1 _si

question about bitfields to decode websocket header

2018-11-07 Thread test via Digitalmars-d-learn
I am confused about the bitfields order. mixin(bitfields!( bool, "fin",1, bool, "rsv1", 1, bool, "rsv2", 1, bool, "rsv3", 1, Opcode, "opcode", 4, bool, "mask", 1, ubyte, "_size"

Re: need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
On Monday, 22 October 2018 at 12:32:57 UTC, test wrote: On Monday, 22 October 2018 at 12:16:50 UTC, Stanislav Blinov wrote: On Monday, 22 October 2018 at 12:03:22 UTC, test wrote: You're trying to call a static function 'getThis' on Fiber. The type 'Fiber' is really a Proxy!FiberS. Proxy doesn't

Re: need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
On Monday, 22 October 2018 at 12:16:50 UTC, Stanislav Blinov wrote: On Monday, 22 October 2018 at 12:03:22 UTC, test wrote: You're trying to call a static function 'getThis' on Fiber. The type 'Fiber' is really a Proxy!FiberS. Proxy doesn't have a static getThis() function. So the compiler tries

Re: need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
On Monday, 22 October 2018 at 11:59:21 UTC, test wrote: On Monday, 22 October 2018 at 11:42:59 UTC, test wrote: I try made a simple example but it has no error: I find the way to show the error: https://run.dlang.io/is/f8cULz import std.traits; struct FiberS { static auto getThis()

Re: need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
On Monday, 22 October 2018 at 11:42:59 UTC, test wrote: On Monday, 22 October 2018 at 11:18:20 UTC, Stanislav Blinov wrote: Error: template instance `TypeTemplate!(BaseType)` error instantiating I use alias this to allow call static method on proxyType. It work some time, but on other case

Re: need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
On Monday, 22 October 2018 at 11:18:20 UTC, Stanislav Blinov wrote: On Monday, 22 October 2018 at 10:49:10 UTC, test wrote: note the added check that the member is not a type: is(typeof(__traits(getMember, BaseType, name))). You'll still need to iterate overloads if you want to get all static

Re: need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
On Monday, 22 October 2018 at 10:49:10 UTC, test wrote: On Monday, 22 October 2018 at 10:45:07 UTC, test wrote: On Monday, 22 October 2018 at 10:29:56 UTC, Stanislav Blinov wrote: extern(C) void main(){ GetPub!XX; } https://run.dlang.io/is/f295qE

Re: need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
On Monday, 22 October 2018 at 10:45:07 UTC, test wrote: On Monday, 22 October 2018 at 10:29:56 UTC, Stanislav Blinov wrote: On Monday, 22 October 2018 at 10:16:22 UTC, test wrote: and On Monday, 22 October 2018 at 10:45:07 UTC, test wrote: test1.d = alias Fn1 = void

Re: need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
On Monday, 22 October 2018 at 10:29:56 UTC, Stanislav Blinov wrote: On Monday, 22 October 2018 at 10:16:22 UTC, test wrote: I try use traits get all public static function of a struct pass to template... how to do this ? void allFunctions(T)() { import std.stdio; foreach (name; __tr

need help about get all public static function name

2018-10-22 Thread test via Digitalmars-d-learn
I try use traits get all public static function of a struct pass to template. Compiler report " .Function is not accessible from module " with __traits(isStaticFunction, __traits(getMember, Type , name)). If I add " __traits(getProtection, __traits(getMember, Type, name)) == "public" befor

Re: betterC generate dynamic array throw Error: TypeInfo cannot be used with -betterC

2018-10-17 Thread test via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 16:50:36 UTC, Paul Backus wrote: On Wednesday, 17 October 2018 at 07:01:21 UTC, test wrote: simple example: you can not use functionAttributes from betterC

betterC generate dynamic array throw Error: TypeInfo cannot be used with -betterC

2018-10-17 Thread test via Digitalmars-d-learn
test1: module test1; import test2; enum X = getR(1,3); void main(string[] args){} test2: module test2; struct R { int i; } R[] getR(int a, int b){ R[] r; r ~= R(a); r ~= R(b); return r; } to build wi

Re: betterC generate dynamic array throw Error: TypeInfo cannot be used with -betterC

2018-10-17 Thread test via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 07:01:21 UTC, test wrote: test2.d(3): Error: TypeInfo cannot be used with -betterC the first problem is the error message is not clear and can be improved. And my question is how to workaround this to make it work with betterC.

how to get UDA only for methods

2018-10-16 Thread test via Digitalmars-d-learn
I need get the Route UDA only for method without (static methods, property, constructor, destructor), dont know how to do it. Route[] getRoutes(T)(){ Route[] routes; foreach(int i, m; __traits(allMembers, T) ){ pragma(msg, m.stringof); static fore