Re: Hex constant method starts from ".a": 0xCCCCCC.argb

2020-12-13 Thread Виталий Фадеев via Digitalmars-d-learn
On Monday, 14 December 2020 at 05:37:21 UTC, Paul Backus wrote: On Monday, 14 December 2020 at 05:27:40 UTC, Виталий Фадеев wrote: ".rgb" Compiled fine. ".argb" Compilation error. Source: https://run.dlang.io/is/ULQ4kh It's parsing the `.a` in `.argb` as part of the number: auto color

Re: Hex constant method starts from ".a": 0xCCCCCC.argb

2020-12-13 Thread Paul Backus via Digitalmars-d-learn
On Monday, 14 December 2020 at 05:27:40 UTC, Виталий Фадеев wrote: ".rgb" Compiled fine. ".argb" Compilation error. Source: https://run.dlang.io/is/ULQ4kh It's parsing the `.a` in `.argb` as part of the number: auto color = 0x00AABBCC.a rgb; // what the compiler sees You can fix it

Re: Hex constant method starts from ".a": 0xCCCCCC.argb

2020-12-13 Thread Виталий Фадеев via Digitalmars-d-learn
On Monday, 14 December 2020 at 05:24:39 UTC, Виталий Фадеев wrote: ... msg ... But...: Color rgb( uint color ) { return Color( cast( uint ) ( ( ( color & 0x00FF ) << 16 ) | ( ( color & 0xFF00 ) ) | ( (

Hex constant method starts from ".a": 0xCCCCCC.argb

2020-12-13 Thread Виталий Фадеев via Digitalmars-d-learn
We have: static import winapi=core.sys.windows.windows; struct Color { union { winapi.COLORREF native; struct { ubyte r; ubyte g; ubyte b; } } ubyte a =

Re: Can I use dub to generate docs?

2020-12-13 Thread Paul Backus via Digitalmars-d-learn
On Monday, 14 December 2020 at 02:54:12 UTC, Jack wrote: like dmd's -D flag? dub build --build=docs

Can I use dub to generate docs?

2020-12-13 Thread Jack via Digitalmars-d-learn
like dmd's -D flag?

Re: presence of function template prevents diagnostic

2020-12-13 Thread kdevel via Digitalmars-d-learn
On Monday, 16 November 2020 at 18:34:14 UTC, Max Haughton wrote: [...] Probably should be a bug. filed as Issue 21481

Re: uncaught exceptions: stack trace truncated at NUL char

2020-12-13 Thread kdevel via Digitalmars-d-learn
On Sunday, 13 December 2020 at 22:40:53 UTC, Paul Backus wrote: This is definitely a bug. filed as Issue 21480

Re: uncaught exceptions: stack trace truncated at NUL char

2020-12-13 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 13 December 2020 at 21:22:16 UTC, kdevel wrote: On Sunday, 13 December 2020 at 20:58:42 UTC, rikki cattermole wrote: [...] String literals are null terminated by the compiler. It is very useful for communicating with C. Sure, but in the example given there is an embedded NUL

Re: uncaught exceptions: stack trace truncated at NUL char

2020-12-13 Thread kdevel via Digitalmars-d-learn
On Sunday, 13 December 2020 at 20:58:42 UTC, rikki cattermole wrote: [...] String literals are null terminated by the compiler. It is very useful for communicating with C. Sure, but in the example given there is an embedded NUL which as part of an exception msg. If caught everything works

Re: uncaught exceptions: stack trace truncated at NUL char

2020-12-13 Thread rikki cattermole via Digitalmars-d-learn
On 14/12/2020 9:56 AM, kdevel wrote: On Sunday, 13 December 2020 at 20:25:06 UTC, KapyoniK wrote: Is it really a bug ? \0 truncates the string, as mentionned on this page : https://en.wikipedia.org/wiki/Null-terminated_string I thought the D runtime is written in D (with D strings)?!?

Re: uncaught exceptions: stack trace truncated at NUL char

2020-12-13 Thread kdevel via Digitalmars-d-learn
On Sunday, 13 December 2020 at 20:25:06 UTC, KapyoniK wrote: Is it really a bug ? \0 truncates the string, as mentionned on this page : https://en.wikipedia.org/wiki/Null-terminated_string I thought the D runtime is written in D (with D strings)?!?

Re: uncaught exceptions: stack trace truncated at NUL char

2020-12-13 Thread KapyoniK via Digitalmars-d-learn
On Sunday, 13 December 2020 at 11:51:19 UTC, kdevel wrote: ~~~char2.d void main () { import std.stdio; import std.conv; char [2] win = [0, 'X']; auto ne = new Exception ("A " ~ win.to!string ~ " B"); try throw ne; catch (Exception e) writeln ("exception caught: e.msg =

Re: How to check that function gets ref parameter?

2020-12-13 Thread Basile B. via Digitalmars-d-learn
On Sunday, 13 December 2020 at 16:41:06 UTC, Andrey Zherikov wrote: I'm trying to check that function has 'ref' parameter. The only way I found so far is to use std.traits.Parameters. Here is the code I have: void f(int) {} void g(ref int) {} void main() {

Re: UFCS functions with both pointers and refs

2020-12-13 Thread Dave P. via Digitalmars-d-learn
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote: On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote: Do I have to write both and have one forward to the other for more complicated functions? For free functions, yes. Is there any way to write the function as a

Re: UFCS functions with both pointers and refs

2020-12-13 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote: If I define a method on a type, then I can call it both through a pointer and through a reference and the compiler does the right thing. Eg: struct Foo { int x; void fooey(){ x++; } void report(){

UFCS functions with both pointers and refs

2020-12-13 Thread Dave P. via Digitalmars-d-learn
If I define a method on a type, then I can call it both through a pointer and through a reference and the compiler does the right thing. Eg: struct Foo { int x; void fooey(){ x++; } void report(){ printf("%d\n", x); } } int main(){ Foo f; f.fooey;

Re: MonoTimeImpl!(ClockType.normal) failed to get the frequency of the system's monotonic clock.

2020-12-13 Thread Jack via Digitalmars-d-learn
On Sunday, 13 December 2020 at 17:34:26 UTC, rikki cattermole wrote: Did you initialize the D runtime before you called the D code? (assuming C main). wow, thanks for such quck response. That's exactly what I missing in this function: version(Posix) {

Re: MonoTimeImpl!(ClockType.normal) failed to get the frequency of the system's monotonic clock.

2020-12-13 Thread rikki cattermole via Digitalmars-d-learn
Did you initialize the D runtime before you called the D code? (assuming C main).

MonoTimeImpl!(ClockType.normal) failed to get the frequency of the system's monotonic clock.

2020-12-13 Thread Jack via Digitalmars-d-learn
I have this D code base that when I compile to executable, it ran fine, but when I call the very same function from C, I get this error: Aborting from src/core/time.d(2113) MonoTimeImpl!(ClockType.normal) failed to get the frequency of the system's monotonic clock. from source code[1] I

How to check that function gets ref parameter?

2020-12-13 Thread Andrey Zherikov via Digitalmars-d-learn
I'm trying to check that function has 'ref' parameter. The only way I found so far is to use std.traits.Parameters. Here is the code I have: void f(int) {} void g(ref int) {} void main() { writeln(Parameters!f[0].stringof); writeln(__traits(isRef,

uncaught exceptions: stack trace truncated at NUL char

2020-12-13 Thread kdevel via Digitalmars-d-learn
~~~char2.d void main () { import std.stdio; import std.conv; char [2] win = [0, 'X']; auto ne = new Exception ("A " ~ win.to!string ~ " B"); try throw ne; catch (Exception e) writeln ("exception caught: e.msg = <", e.msg, ">"); throw ne; } ~~~ Output: exception