Re: The difference between the dates in years

2024-02-10 Thread Alexander Zhirov via Digitalmars-d-learn
On Saturday, 10 February 2024 at 18:12:07 UTC, Alexander Zhirov wrote: On Saturday, 10 February 2024 at 16:03:32 UTC, H. S. Teoh wrote: On Sat, Feb 10, 2024 at 03:53:09PM +, Alexander Zhirov via Digitalmars-d-learn wrote: Is it possible to calculate the difference between dates in years

Re: The difference between the dates in years

2024-02-10 Thread Alexander Zhirov via Digitalmars-d-learn
On Saturday, 10 February 2024 at 16:03:32 UTC, H. S. Teoh wrote: On Sat, Feb 10, 2024 at 03:53:09PM +, Alexander Zhirov via Digitalmars-d-learn wrote: Is it possible to calculate the difference between dates in years using regular means? Something like that ``` writeln(Date(1999, 3, 1

The difference between the dates in years

2024-02-10 Thread Alexander Zhirov via Digitalmars-d-learn
Is it possible to calculate the difference between dates in years using regular means? Something like that ``` writeln(Date(1999, 3, 1).diffMonths(Date(1999, 1, 1))); ``` At the same time, keep in mind that the month and day matter, because the difference between the year, taking into

Re: Vibe D: Get access to files

2024-02-09 Thread Alexander Zhirov via Digitalmars-d-learn
In the files, dt specified the path to the files from the root `/style.css` and now, with any path from the root, files are loaded into the page, instead of `style.css`. My mistake.

Re: How to get the client's MAC address in Vibe

2024-02-09 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 8 February 2024 at 01:05:57 UTC, Mengu wrote: On Wednesday, 7 February 2024 at 22:16:54 UTC, Alexander Zhirov wrote: Is there a way to identify a client by MAC address when using the Vibe library? The `NetworkAddress` [structure](https://vibed.org/api/vibe.core.net/NetworkAddress)

Re: How to get the client's MAC address in Vibe

2024-02-09 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 8 February 2024 at 14:21:13 UTC, Steven Schveighoffer wrote: On Wednesday, 7 February 2024 at 22:16:54 UTC, Alexander Zhirov wrote: Is there a way to identify a client by MAC address when using the Vibe library? The `NetworkAddress`

How to get the client's MAC address in Vibe

2024-02-07 Thread Alexander Zhirov via Digitalmars-d-learn
Is there a way to identify a client by MAC address when using the Vibe library? The `NetworkAddress` [structure](https://vibed.org/api/vibe.core.net/NetworkAddress) does not provide such features. Or did I miss something?

Re: Search for the dialog library

2023-10-15 Thread Alexander Zhirov via Digitalmars-d-learn
On Sunday, 15 October 2023 at 21:46:44 UTC, Dmitry Ponyatov wrote: Maybe it's time to port the old warm tubby Turbo Vision into the glorious D lang? https://github.com/magiblot/tvision Since there was a conversation about the implementation of the wrapper, it is easier to write a wrapper

Search for the dialog library

2023-10-14 Thread Alexander Zhirov via Digitalmars-d-learn
Colleagues, tell me, please, is there any library on D for drawing [dialog](https://invisible-island.net/dialog/images/dialog.png) boxes using the dialog library, like in Python [pythondialog](https://pypi.org/project/pythondialog/)?

Re: Redirecting standard streams in Windows

2023-07-19 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 19 July 2023 at 00:13:04 UTC, Adam D Ruppe wrote: How does the cat program know what the encoding of the file is? Try opening it in notepad or something and specifying the encoding. I betcha it is perfectly fine. Strange. Everything works correctly on the command line. And the

Re: Redirecting standard streams in Windows

2023-07-18 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 18 July 2023 at 22:09:40 UTC, Adam D Ruppe wrote: You need to use WriteFile when it is redirected, which you can detect with GetFileType to see if it is a character device or not. The redirection issue has been resolved. Another one has now emerged. Since I have unicode, I need

Re: Redirecting standard streams in Windows

2023-07-18 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 18 July 2023 at 22:12:17 UTC, Alexander Zhirov wrote: with threads streams*

Re: Redirecting standard streams in Windows

2023-07-18 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 18 July 2023 at 22:09:40 UTC, Adam D Ruppe wrote: On Tuesday, 18 July 2023 at 21:31:54 UTC, Alexander Zhirov wrote: HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE); WriteConsoleW(h_stderr, str.ptr, cast(DWORD)str.length, NULL, NULL); If you checked the return value of

Redirecting standard streams in Windows

2023-07-18 Thread Alexander Zhirov via Digitalmars-d-learn
I'm trying to redirect unicode in the windows console, but when redirecting, empty files are created. If i do it without redirects, then the text is displayed correctly in the console: ```d import core.sys.windows.windows; import std.stdio; void main() { wstring str = "Just text...";

Re: Initializing an associative array into a variable when it is created

2023-07-16 Thread Alexander Zhirov via Digitalmars-d-learn
On Sunday, 16 July 2023 at 11:16:55 UTC, Danilo wrote: Would a static constructor be okay? This way the static data is not initialized at every `new` and object creation is faster. Alternatively, i can think about your proposal. At the moment, I have solved my problem using the following

Re: Initializing an associative array into a variable when it is created

2023-07-16 Thread Alexander Zhirov via Digitalmars-d-learn
On Saturday, 15 July 2023 at 23:34:22 UTC, Danilo wrote: Works fine, if you add a semicolon at the end. I'm sorry. I didn't put the question quite correctly. Yes, this is how the array is initialized. I'm trying to describe it all in a class. I.e. I need to create a variable in the class

Initializing an associative array into a variable when it is created

2023-07-15 Thread Alexander Zhirov via Digitalmars-d-learn
I still don't understand how to make this entry correct. I have a static array that I want to use exactly as an array (the structure doesn't quite fit): ```d string[][string] arr = [ "one": ["abc", "def"], "two": ["ghi", "jkl"], "three": ["mno", "pqr"] ] ``` There are the same

Re: Logging logs in Windows

2023-04-18 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 18 April 2023 at 12:08:35 UTC, Richard (Rikki) Andrew Cattermole wrote: Sounds like a simple case of not linking against the right library: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-reporteventa Library Advapi32.lib DLL Advapi32.dll Should be as

Re: Logging logs in Windows

2023-04-18 Thread Alexander Zhirov via Digitalmars-d-learn
On Saturday, 4 February 2023 at 14:48:55 UTC, Richard (Rikki) Andrew Cattermole wrote: I.e. here are my functions for syslog and Windows Event log (I won't copy it all, it won't be helpful & the file log function is giant compared). ```d void syslog() { version

undefined reference to "main"

2023-04-05 Thread Alexander Zhirov via Digitalmars-d-learn
How to compile the example given in the book correctly? When compiling, an error occurs that the main function is missing. If I replace `shared static this()` with `void main()', then everything starts. What does the compilation string in `dub` and `dmd` look like correctly? ```d import

Re: Convert binary to UUID from LDAP

2023-03-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 28 March 2023 at 13:18:59 UTC, Kagamin wrote: This guid is (int,short,short,byte[8]) in little endian byte order. So if you want to convert it to big endian, you'll need to swap bytes in those int and two shorts. ``` ubyte[] guid=... int* g1=cast(int*)guid.ptr; *g1=bswap(*g1); ```

Re: Convert binary to UUID from LDAP

2023-03-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 28 March 2023 at 08:15:03 UTC, Alexander Zhirov wrote: So far it has been possible to convert like this The idea was borrowed from [here](https://elixirforum.com/t/using-active-directory-guid-with-ecto-uuid-field/15904).

Re: Convert binary to UUID from LDAP

2023-03-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 28 March 2023 at 05:26:08 UTC, Alexander Zhirov wrote: When converting to HEX, I get the string `121F4C264DED5E41A33F445B0A1CAE32`, in which some values are reversed. I found ways on the Internet to transform the permutation method into the desired result, but most likely it will

Re: Convert binary to UUID from LDAP

2023-03-27 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 27 March 2023 at 18:39:19 UTC, Alexander Zhirov wrote: I mean get the UUID data type itself. Just using [this example](https://dlang.org/phobos/std_uuid.html#.UUID) `cast(ubyte[16])ubyte[]` will not work, conversion error. ```d

Re: Convert binary to UUID from LDAP

2023-03-27 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 28 March 2023 at 00:51:43 UTC, Steven Schveighoffer wrote: auto uuid = UUID(*cast(ubyte[16]*)youruuiddata.ptr); ```d ubyte[] arr = cast(ubyte[])value.attributes["objectGUID"][0].dup; writeln(UUID(cast(ubyte[16])arr.ptr)); ``` `Error: cannot cast expression 'cast(ubyte*)arr' of

Re: Convert binary to UUID from LDAP

2023-03-27 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 27 March 2023 at 18:33:46 UTC, novice2 wrote: https://run.dlang.io/is/JP01aZ ``` void main(){ import std.stdio: writeln; import std.format: format; ubyte[] a = [159, 199, 22, 163, 13, 74, 145, 73, 158, 112, 7, 192, 12, 193, 7, 194]; string b

Convert binary to UUID from LDAP

2023-03-27 Thread Alexander Zhirov via Digitalmars-d-learn
I get `objectGUID` data from LDAP as binary data. I need to convert `ubyte[]` data into a readable `UUID`. As far as I understand, it is possible to do this via `toHexString()`, but I have reached a dead end. Is there a way to make it more elegant, like [this

Re: Implicit type conversion depending on assignment

2023-03-24 Thread Alexander Zhirov via Digitalmars-d-learn
On Friday, 24 March 2023 at 09:46:26 UTC, Jacob Shtokolov wrote: BTW, you can also `alias this` your struct value and then use `std.conv : to` for casting, if you don't need specific casting rules. I don't quite understand what you mean? Could you show me an example?

Re: Implicit type conversion depending on assignment

2023-03-23 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 23 March 2023 at 14:36:11 UTC, Alexander Zhirov wrote: I wanted WITHOUT explicit casting. I also have thoughts about using [templates](https://dlang.org/spec/template.html#this_rtti), but I don't have enough experience yet how to implement it.

Re: Implicit type conversion depending on assignment

2023-03-23 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 23 March 2023 at 14:19:31 UTC, user1234 wrote: omg, let's rewrite this... I meant something like that. But you can't do that. I wanted WITHOUT explicit casting. ```d struct MyVal { private string value; @property auto toString(T)() { return value.to!T;

Re: Implicit type conversion depending on assignment

2023-03-23 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 23 March 2023 at 13:38:51 UTC, Alexander Zhirov wrote: Is it possible to convert such records inside the structure to the assigned type? ```d struct MyVal { string value; // Here it would be possible to use an alias to this, but it can only be used 1 time } auto a =

Implicit type conversion depending on assignment

2023-03-23 Thread Alexander Zhirov via Digitalmars-d-learn
Is it possible to convert such records inside the structure to the assigned type? ```d struct MyVal { string value; // Here it would be possible to use an alias to this, but it can only be used 1 time } auto a = MyVal("100"); auto b = MyVal("11.2"); int MyInt = a;//

Re: Formatted date

2023-03-22 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 22 March 2023 at 17:53:39 UTC, Steven Schveighoffer wrote: D's datetime intentionally does not tackle formatting -- it's a huge undertaking. There is an option on code.dlang.org: https://code.dlang.org/packages/datefmt -Steve I'll try it tomorrow, thanks!

Formatted date

2023-03-22 Thread Alexander Zhirov via Digitalmars-d-learn
Tell me, how can I use such a date conversion mechanism? I didn't find [something](https://www.php.net/manual/en/datetime.format.php) similar on the forum. Convert date from received time ``` Clock.currTime().toSimpleString() ``` So that i can get a more readable look: `2023-Mar-22

Re: Sort Associative Array by Key

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
foo.byPair .array .sort!((a, b) => a.key < b.key) .map!(a => a.value); Is it possible to specify in `map` to return the result `[a.key] = a.value`? To make the result look like `[key:[val], key:[val]]`

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 19:32:22 UTC, Ali Çehreli wrote: This should do it: [...] Yes, it works! I'll try it tomorrow on a large array of data. Thank you very much! This turns out to be a simple loop with a comparison of the existence of a key (whether it is included in an array or

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 18:57:00 UTC, Anonymouse wrote: Can you explain how you determine how/if two entries are different? I apologize. I have not written, in fact, what I need to get. Array `A` ```d [ 4:["id":"4", "deleted":"f", "name":"6.2"], 3:["id":"3", "deleted":"f",

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 18:08:40 UTC, Ali Çehreli wrote: Just because this sounds complicated, I hope the data structure can be designed differently to be more friendly to this operation. (?) Ali This is the result of an SQL query. Roughly speaking, I need to compare the result of

Comparison of multidimensional associative arrays

2023-02-08 Thread Alexander Zhirov via Digitalmars-d-learn
Not an easy task for me, maybe you can advise your compact solution. There are two associative arrays of type `string[string][int]`. It is necessary to find the differences and return them when comparing: ```d [ 6:["id":"6", "deleted":"f", "name":"6.2_test"], 5:["id":"5",

Re: compile: link dynamic OR static library in Windows

2023-02-06 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 6 February 2023 at 08:23:37 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] Yes, your solution works. I apologize for my inattention. I should have checked earlier in your way. Most likely Adam has a [problem](https://github.com/adamdruppe/arsd/issues/364) with linking in the

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 6 February 2023 at 06:59:09 UTC, Richard (Rikki) Andrew Cattermole wrote: On other platforms the -Lfile I think would work. On Windows you have to link against the import library not DLL directly. You can pass it to the compiler: $ dmd -i "-L/LIBPATH:C:\Program

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 6 February 2023 at 05:45:35 UTC, Richard (Rikki) Andrew Cattermole wrote: Ah doh, MSVC link doesn't use -L. $ dmd -i "-L/LIBPATH:C:\Program Files\PostgreSQL\15\lib" -Llpq app.d I think that is the option you want. Worst case scenario just copy the files to your working directory

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Monday, 6 February 2023 at 05:20:33 UTC, Richard (Rikki) Andrew Cattermole wrote: Source files go after flags. $ dmd -i -L'-LC:\Program Files\PostgreSQL\15\lib' -Llpq app.d For some reason, the `obj` file is link instead of the library. ```sh C:\sources\pxe-restore\source>dmd

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Sunday, 5 February 2023 at 13:37:16 UTC, user1234 wrote: try ``` dmd -i app.d -L'-LC:\Program Files\PostgreSQL\15\lib' -Llpq ``` the first linker command gives a search path, the second a libname. It doesn't work ```sh C:\sources\pxe-restore\source>dmd -i app.d -L'-LC:\Program

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Saturday, 4 February 2023 at 15:56:41 UTC, Richard (Rikki) Andrew Cattermole wrote: On Windows you don't link directly against a DLL. You link against a static library (.lib) of the same name. The binding doesn't change between a static library and a shared library as long as you're

Re: compile: link dynamic OR static library in Windows

2023-02-04 Thread Alexander Zhirov via Digitalmars-d-learn
On Saturday, 4 February 2023 at 17:02:11 UTC, Ferhat Kurtulmuş wrote: On Windows, dub's default behavior is to search for "foo.lib", usually compiled with Visual Studio C/C++ compilers. However, you have mingw-compiled "libfoo.a". I would not use MinGW-compiled libs with d compilers. I don't

compile: link dynamic OR static library in Windows

2023-02-04 Thread Alexander Zhirov via Digitalmars-d-learn
I have never programmed in Windows, so I don't quite understand how to link the library correctly. I have a compiled Postgres library from under mingw. There is both a static library `*.a` and a dynamic library `*.dll`. I don't understand how to compile my project correctly at all. I tried to

Re: Logging logs in Windows

2023-02-04 Thread Alexander Zhirov via Digitalmars-d-learn
On Saturday, 4 February 2023 at 14:48:55 UTC, Richard (Rikki) Andrew Cattermole wrote: I.e. here are my functions for syslog and Windows Event log I'll try to check. Thank you very much!

Re: Logging logs in Windows

2023-02-04 Thread Alexander Zhirov via Digitalmars-d-learn
On Friday, 3 February 2023 at 18:02:59 UTC, Richard (Rikki) Andrew Cattermole wrote: Here is a starting point that I myself have used in the past: I understand that programming under Windows is a shame for a programmer, but is there really no ready-made solution for using the system log in

Re: Logging logs in Windows

2023-02-03 Thread Alexander Zhirov via Digitalmars-d-learn
On Friday, 3 February 2023 at 16:00:55 UTC, Richard (Rikki) Andrew Cattermole wrote: Yes syslog is not available on Windows as that is a Posix API. All of your calls to syslog should be guarded by a version for Posix. Is there an analogue for Windows? And is it possible to implement it with

Logging logs in Windows

2023-02-03 Thread Alexander Zhirov via Digitalmars-d-learn
I wrote a small utility in Linux. I want to build it for Windows. He swears at some parts of the code like this: ```powershell C:\sources\pxe-restore>dub build -b release Starting Performing "release" build using dmd for x86_64. Building pxe-restore ~master: building configuration

Re: Get the class name without casting the type

2022-11-15 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 15 November 2022 at 14:26:22 UTC, Imperatorn wrote: Side-note, you don't override interface members, you implement them. My knowledge of D is still modest, most likely, I just didn't know that override with interfaces can not be used. Thanks for the hint!

Re: Get the class name without casting the type

2022-11-15 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 15 November 2022 at 14:09:01 UTC, bauss wrote: If you cast to Object and use classinfo.name then you get the expected result of B. Thanks! 

Re: Get the class name without casting the type

2022-11-15 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 15 November 2022 at 12:25:22 UTC, Hipreme wrote: You can do it as `val.classinfo.name` Yes, I have already done so, but the result is the same, actually :) ```d app.A: It's ok! app.A: It's ok! app.A: It's ok! ```

Get the class name without casting the type

2022-11-15 Thread Alexander Zhirov via Digitalmars-d-learn
Is there any way to get the name of class B? ```d interface A { string text(); } class B : A { override string text() { return ": It's ok!"; } } void main() { A[] a = cast(A[]) new B[3]; B b = new B(); fill(a, b); foreach (val ; a) {

Re: Removing an element from an array

2022-11-10 Thread Alexander Zhirov via Digitalmars-d-learn
On Friday, 11 November 2022 at 05:36:37 UTC, Alexander Zhirov wrote: On Friday, 11 November 2022 at 00:02:09 UTC, Alexander Zhirov wrote: ```d import std.algorithm; arr = arr.remove(arr.countUntil(fragment)); ``` And will this method work? ```d A[] arr; A fragment = new A; ... remove(current

Re: Removing an element from an array

2022-11-10 Thread Alexander Zhirov via Digitalmars-d-learn
On Friday, 11 November 2022 at 00:02:09 UTC, Alexander Zhirov wrote: ```d import std.algorithm; arr = arr.remove(arr.countUntil(fragment)); ``` And will this method work? ```d A[] arr; A fragment = new A; ... remove(current => current == fragment)(arr); ```

Re: Removing an element from an array

2022-11-10 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 10 November 2022 at 23:36:29 UTC, H. S. Teoh wrote: On Thu, Nov 10, 2022 at 11:26:45PM +, Alexander Zhirov via Digitalmars-d-learn wrote: I have an array of self-written class `A`. I'm sorry for my tactlessness, but I'm confused about the modules. How do I correctly find

Removing an element from an array

2022-11-10 Thread Alexander Zhirov via Digitalmars-d-learn
I have an array of self-written class `A`. I'm sorry for my tactlessness, but I'm confused about the modules. How do I correctly find a specific object `fragment` inside the array and delete it? I don't quite understand which modules to use to do this optimally. ```d A[] arr; A fragment =

Re: Passing a string by reference

2022-11-08 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 13:05:09 UTC, Ali Çehreli wrote: Yes. Classes are reference types in D. Class variables are implemented as pointers. Their default value is null. Ali Thanks! 

Re: Passing a string by reference

2022-11-08 Thread Alexander Zhirov via Digitalmars-d-learn
Thanks for answers! On Tuesday, 8 November 2022 at 12:43:47 UTC, Adam D Ruppe wrote: You should almost never use `ref string`. Just use plain `string`. So it's always working with thick pointers? nope, an object isn't created there at all. you should use `new C`. If I create just `A c`,

Passing a string by reference

2022-11-08 Thread Alexander Zhirov via Digitalmars-d-learn
Do I understand correctly that in order for me to pass a string when creating an object, I must pass it by value? And if I have a variable containing a string, can I pass it by reference? Should I always do constructor overloading for a type and a reference to it? In the case of the variable

Re: Write binary data as a file

2022-08-02 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 15:30:13 UTC, Adam D Ruppe wrote: On Tuesday, 2 August 2022 at 11:10:27 UTC, Alexander Zhirov wrote: As a result, I get only a set of text data. my database layer is doing to!string(that_ubyte) which is wrong. gonna see about pushing a fix It's decided! After

Write binary data as a file

2022-08-02 Thread Alexander Zhirov via Digitalmars-d-learn
I'm trying to write a mechanism for writing and reading from Postgres. Using the Adama D. Ruppe library. I write data to Postgres in the form of this code: ```d ubyte[] bytes = cast(ubyte[])read("myFile"); PostgresResult resultQuery = cast(PostgresResult) db.query("insert into

Re: Build for i586

2022-07-29 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 July 2022 at 06:01:17 UTC, Alexander Zhirov wrote: I did a topic a [little earlier](https://forum.dlang.org/thread/hfzsnagofrnlmynyz...@forum.dlang.org) about compiling a compiler for processor Geode LX800. The bottom line is that I have a processor on which I want to compile

Re: Build for i586

2022-07-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 July 2022 at 16:02:11 UTC, kdevel wrote: On Thursday, 28 July 2022 at 15:25:00 UTC, Alexander Zhirov wrote: On Thursday, 28 July 2022 at 13:16:26 UTC, kdevel wrote: On Thursday, 28 July 2022 at 12:45:51 UTC, Alexander Zhirov wrote: [...] I have already downloaded the latest

Re: Build for i586

2022-07-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 July 2022 at 13:16:26 UTC, kdevel wrote: On Thursday, 28 July 2022 at 12:45:51 UTC, Alexander Zhirov wrote: [...] I have already downloaded the latest GCC sources, nothing compiles anyway. How did you manage to get hold of this compiler? ```

Re: Build for i586

2022-07-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 July 2022 at 11:40:09 UTC, kdevel wrote: On Thursday, 28 July 2022 at 10:39:06 UTC, Alexander Zhirov wrote: [...] I don't understand what I need to do. You wrote At first I thought that I needed to rebuild the GCC compiler for the i586 architecture. I downloaded GCC

Re: Build for i586

2022-07-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 July 2022 at 10:26:36 UTC, kdevel wrote: On Thursday, 28 July 2022 at 06:12:49 UTC, Alexander Zhirov wrote: On Thursday, 28 July 2022 at 06:01:17 UTC, Alexander Zhirov wrote: ```sh /root/usr/program/gcc/9.5.0/install/bin/cc app.o -o app -L/root/usr/program/ldc/1.30/install/lib

Re: Build for i586

2022-07-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 July 2022 at 10:26:36 UTC, kdevel wrote: On Thursday, 28 July 2022 at 06:12:49 UTC, Alexander Zhirov wrote: On Thursday, 28 July 2022 at 06:01:17 UTC, Alexander Zhirov wrote: ```sh /root/usr/program/gcc/9.5.0/install/bin/cc app.o -o app -L/root/usr/program/ldc/1.30/install/lib

Re: Build for i586

2022-07-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 July 2022 at 07:16:13 UTC, user1234 wrote: that would be something like `--mcpu=i686 --mattrs=-mmx,-sse` and maybe more to be sure. Fails... ```sh # ldc2 --mcpu=i686 --mattr=-mmx,-sse app.d # ./app Illegal instruction ```

Re: Build for i586

2022-07-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 July 2022 at 06:01:17 UTC, Alexander Zhirov wrote: ```sh /root/usr/program/gcc/9.5.0/install/bin/cc app.o -o app -L/root/usr/program/ldc/1.30/install/lib -lphobos2-ldc -ldruntime-ldc -Wl,--gc-sections -lrt -ldl -lpthread -lm -m32 ``` Even tried with such a flag separately,

Build for i586

2022-07-28 Thread Alexander Zhirov via Digitalmars-d-learn
I did a topic a [little earlier](https://forum.dlang.org/thread/hfzsnagofrnlmynyz...@forum.dlang.org) about compiling a compiler for processor Geode LX800. The bottom line is that I have a processor on which I want to compile the program, is an i586 architecture. The [official

Re: Choosing the correct compiler version

2022-07-25 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 21 July 2022 at 05:44:41 UTC, Alexander Zhirov wrote: I will report on the successes a little later. Result: I downloaded and unpacked the binary version of the `dmd` compiler version [2.097.2](http://downloads.dlang.org/releases/2021/dmd.2.097.2.linux.tar.xz), which runs

Re: Choosing the correct compiler version

2022-07-20 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 19 July 2022 at 23:19:28 UTC, jfondren wrote: Finding an old version that works on your machine will be very easy, but for example the random 2016 build that I grabbed was also too old to build dmd master, so you want to prefer a newer build that still works. It's not necessary to

Re: Choosing the correct compiler version

2022-07-19 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 19 July 2022 at 15:28:44 UTC, Alexander Zhirov wrote: I'm trying to install dmd with my hands in order to build ldc2 from the sources, but I can't: I need to build a compiler under x32 in order to compile a program for the same machine. ```sh dmd2/src/dmd# make -f posix.mak

Choosing the correct compiler version

2022-07-19 Thread Alexander Zhirov via Digitalmars-d-learn
Hello everyone I want to install the `ldc2` compiler on a specific machine `i586`: ```sh ~ $ strings /lib/libc.so.6 | grep GLIBC GLIBC_2.0 GLIBC_2.1 GLIBC_2.1.1 GLIBC_2.1.2 GLIBC_2.1.3 GLIBC_2.2 GLIBC_2.2.1 GLIBC_2.2.2 GLIBC_2.2.3 GLIBC_2.2.4 GLIBC_2.2.6 GLIBC_2.3 GLIBC_2.3.2 GLIBC_2.3.3

Execute the Shell command and continue executing the algorithm

2022-05-30 Thread Alexander Zhirov via Digitalmars-d-learn
I want to run a command in the background during the execution of the algorithm, and without waiting for its actual execution, because it is "infinite", while continuing the execution of the algorithm and then, knowing the ID of the previously launched command, kill the process. So far I have

Why is the compiled file size so huge?

2022-05-27 Thread Alexander Zhirov via Digitalmars-d-learn
I'm trying to compile a file that weighs 3 kilobytes. I'm also linking a self-written dynamic library. I don't understand why the resulting executable file is so huge? After all, all libraries are present: ```sh -rwxr-xr-x 1 root root 6.3M May 27 13:39 app -rw-r--r-- 1 root root 2.9K May 27

Re: Sleep in a cycle

2022-05-22 Thread Alexander Zhirov via Digitalmars-d-learn
My schoolboy mistake. Thank you, [Adam](https://forum.dlang.org/post/mbbampewwcrkkltjl...@forum.dlang.org)! On Saturday, 21 May 2022 at 11:17:04 UTC, Alain De Vos wrote: Or you could capture a sigint and close the file then. Yes, exactly, I was thinking in this direction. Probably not quite

Sleep in a cycle

2022-05-20 Thread Alexander Zhirov via Digitalmars-d-learn
I have a loop spinning, I want to pause in it in order to repeat the next iteration. An error is displayed during compilation. ```d import std.stdio; import modules.monitors; //my module import core.thread; int main(string[] args) { string path = "mswitch.log"; if (args.length > 1)

Re: Including C sources in a DUB project

2022-05-10 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 05:11:10 UTC, Alexander Zhirov wrote: dub.settings.json It's written about it [here](https://dub.pm/settings)

Re: Including C sources in a DUB project

2022-05-10 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 22:12:52 UTC, Dennis wrote: It depends on whether your DMD or LDC installation comes first in your PATH environment variable. Both ship with a `dub` executable that uses their compiler as default. I came across something else like this. Created a

Re: Including C sources in a DUB project

2022-05-10 Thread Alexander Zhirov via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 19:13:21 UTC, Dennis wrote: It has an example directory: https://github.com/dlang/dub/tree/master/examples And if there are two compilers in the system - `dmd` and `ldc`, which compiler chooses `dub.json`? And how do I specify the specific compiler I want?

Re: Including C sources in a DUB project

2022-05-09 Thread Alexander Zhirov via Digitalmars-d-learn
On Friday, 6 May 2022 at 11:31:27 UTC, Alexander Zhirov wrote: Does anyone have examples of such a configuration? I managed to do it like this: ```js { "name": "app", "authors": [ "Alexander Zhirov" ], "description": "MyProgram", "dflags": [ "-i" ],

Re: Including C sources in a DUB project

2022-05-06 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 5 May 2022 at 06:05:55 UTC, Alexander Zhirov wrote: It turns out to compile everything manually, but I would like to do it all through the dub project. Does anyone have examples of such a configuration?

Re: Using regular expressions when reading a file

2022-05-06 Thread Alexander Zhirov via Digitalmars-d-learn
On Friday, 6 May 2022 at 05:40:52 UTC, forkit wrote: auto myTuple = line.split(" = "); Well, only if as a strict form :)

Re: Using regular expressions when reading a file

2022-05-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 5 May 2022 at 19:19:26 UTC, Ali Çehreli wrote: Couldn't help myself from improving. :) The following regex works in my Linux console. No issues with '\n'. (?) It also allows for leading and trailing spaces: import std.regex; import std.stdio; import std.algorithm; import

Re: Using regular expressions when reading a file

2022-05-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 5 May 2022 at 18:58:41 UTC, H. S. Teoh wrote: You don't have to. Just add a `$` to the end of your regex, and it should match the newline. If you put it outside the capture parentheses, it will not be included in the value. In fact, it turned out to be much easier. It was just

Re: Using regular expressions when reading a file

2022-05-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 5 May 2022 at 18:15:28 UTC, H. S. Teoh wrote: auto m = matchFirst(line, p_property); Yes, it looks more attractive. Thanks! I just don't quite understand how `matchFirst` works. I seem to have read the [description](https://dlang.org/phobos/std_regex.html#Captures), but

Using regular expressions when reading a file

2022-05-05 Thread Alexander Zhirov via Digitalmars-d-learn
I want to use a configuration file with external settings. I'm trying to use regular expressions to read the `Property = Value` settings. I would like to do it all more beautifully. Is there any way to get rid of the line break character? How much does everything look "right"?

Re: Including C sources in a DUB project

2022-05-05 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 5 May 2022 at 16:23:18 UTC, H. S. Teoh wrote: I don't know how to do it using dub, but you could use pragma(lib) in one (or more) of your source files as a workaround: pragma(lib, "m"); pragma(lib, "X11"); pragma(lib, "Xrandr"); I remember a long time

Including C sources in a DUB project

2022-05-05 Thread Alexander Zhirov via Digitalmars-d-learn
I'm sure there is such a topic on the forum, but after scrolling through the search, I didn't find anything. The bottom line is that I want to enable compilation of C sources in DUB and then build the project with the connection of libraries. I would like to see an example of such a `dub.json`

Re: How do I get the screen resolution?

2022-04-28 Thread Alexander Zhirov via Digitalmars-d-learn
On Thursday, 28 April 2022 at 22:51:02 UTC, Christopher Katko wrote: Are you sure about that? Well, if we're talking about programming, then most likely I need to work with something like this :) https://en.wikipedia.org/wiki/Display_Data_Channel And how to do it - I can't find.

How do I get the screen resolution?

2022-04-28 Thread Alexander Zhirov via Digitalmars-d-learn
Are there any methods to get the screen resolution? On C/C++ from under X11, it is not possible to do this on the command line via SSH, since the display is not defined. And is it possible to do this somehow by means of D, pulling out the system resolution of the installed display?

Re: Library for image editing and text insertion

2022-04-27 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 17:07:54 UTC, matheus wrote: I think in the first time running any D compiler, it should blink in the terminal in Yellow/Pink or whatever color you like, and show some info like: Are you starting a new project any need some libs? Do you know about arsd? If not

Re: Library for image editing and text insertion

2022-04-27 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 16:37:21 UTC, Alexander Zhirov wrote: On Wednesday, 27 April 2022 at 16:07:53 UTC, Adam D Ruppe wrote: How small did it get? ```sh dmd: 3136896 byte ldc: 223952 byte ``` but uses libraries ldc-shared.so ```sh linux-vdso.so.1 (0x7ffef5d2d000)

Re: Library for image editing and text insertion

2022-04-27 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 16:07:53 UTC, Adam D Ruppe wrote: How small did it get? ```sh dmd: 3136896 byte ldc: 223952 byte ``` And with my libs if you import the other ones like `arsd.png` or `arsd.jpeg` directly instead of `arsd.image` that MIGHT help trim it down by removing support

Re: Library for image editing and text insertion

2022-04-27 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 11:59:20 UTC, Bastiaan Veelo wrote: Or use LDC. Gorgeous! LDC has compressed my code at times! Thanks again to everyone for help! Special thanks to **Adam Ruppe**

Re: Library for image editing and text insertion

2022-04-27 Thread Alexander Zhirov via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 08:29:27 UTC, Alexander Zhirov wrote: On Wednesday, 27 April 2022 at 07:42:31 UTC, Alexander Zhirov wrote: On Wednesday, 27 April 2022 at 00:03:25 UTC, Adam Ruppe wrote: Sample code would be: 1) How to write to jpeg correctly? That's how I managed to write to

  1   2   >