[std.process] get Pid class by Process ID?

2018-07-11 Thread Jonathan Villa via Digitalmars-d-learn
Hi everyone, Is it possible to get a Pid (class) from a process id (int)?. I need to use the wait function from std.process but it asks for a Pid, and I have only the process id (integer). auto pd = new Pid(processID); // doesn't work I want to verify that the parent process is still alive,

Re: what's wrong with my class?

2016-05-04 Thread Jonathan Villa via Digitalmars-d-learn
On Thursday, 5 May 2016 at 00:03:34 UTC, Brian Schott wrote: On Wednesday, 4 May 2016 at 23:19:08 UTC, Jonathan Villa wrote: What I'm doing wrong? :< All right. D's type system is marking the `Session` constructor as `shared`. This makes the check `static if

Re: what's wrong with my class?

2016-05-04 Thread Jonathan Villa via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 23:33:28 UTC, Brian Schott wrote: On Wednesday, 4 May 2016 at 23:19:08 UTC, Jonathan Villa wrote: What I'm doing wrong? :< I see that the types of `id_user` aren't necessarily the same between `create` and `this`. Oh, they are indeed same (alias). I wrote uint

what's wrong with my class?

2016-05-04 Thread Jonathan Villa via Digitalmars-d-learn
... import std.experimental.allocator : make, dispose; import std.experimental.allocator.mallocator : Mallocator; public synchronized class Session { private: ASI parent; cUser user; public: static Session create(ASI _parent, accounts.user.id_user_t id_user)

Re: what is missing here?

2016-05-03 Thread Jonathan Villa via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 16:13:07 UTC, ag0aep6g wrote: On 03.05.2016 18:03, Jonathan Villa wrote: Types are not values. You cannot return a type from a function. Use aliases instead: alias user_id_t = typeof(dummy1); alias name_t = typeof(dummy2); /* ... etc ...

what is missing here?

2016-05-03 Thread Jonathan Villa via Digitalmars-d-learn
public final class accounts { public: static table_user user; } public final class table_user { private: static uint32 dummy1; static string dummy2; static DateTime dummy3; static ubyte dummy4; public: static @property auto user_id_t()

Re: Question about dub and imports

2016-04-18 Thread Jonathan Villa via Digitalmars-d-learn
On Monday, 18 April 2016 at 21:23:02 UTC, Jonathan Villa wrote: I'm trying to build a vibe.d application, but I made a little library (just source code) that I want to add to the project. [...] Close the question, looks like I found it: importPaths.

Question about dub and imports

2016-04-18 Thread Jonathan Villa via Digitalmars-d-learn
I'm trying to build a vibe.d application, but I made a little library (just source code) that I want to add to the project. So, in the generated dub.sdl file I added at the end: sourcePaths "../D/src" sourceFiles "../D/src/alfred/package.d" The problem is at build time DUB tries to create a

Re: What is best way to get see function from separate file

2016-04-10 Thread Jonathan Villa via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:57:45 UTC, Suliman wrote: I like it. Am i right understand that it prevent creation unneeded of new instance of logger? No, you need to pass a valid instance in foo(...), It should have been created before the call to foo(...). I prefer the second way

Re: What is best way to get see function from separate file

2016-04-10 Thread Jonathan Villa via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:26:57 UTC, Suliman wrote: Sorry for wrong posting! I have got logger instance in App.d void main() { ... FileLogger fLogger = new FileLogger("ErrorLog.txt"); foo(); } utils.d: foo() { // I need logging here } Also I have file utils.d that include stand-alone

Re: What is best way to get see function from separate file

2016-04-10 Thread Jonathan Villa via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:36:19 UTC, Jonathan Villa wrote: On Sunday, 10 April 2016 at 18:26:57 UTC, Suliman wrote: Other whay is to leave FileLogger instance in a separated module: logger.d public static FileLogger fLogger; App.d import logger; //the module void main() { //

Re: Best properly way to destroy a 2 dimensional array?

2016-04-08 Thread Jonathan Villa via Digitalmars-d-learn
On Friday, 8 April 2016 at 15:21:50 UTC, Steven Schveighoffer wrote: On 4/8/16 11:08 AM, Jonathan Villa wrote: On Thursday, 7 April 2016 at 16:13:59 UTC, Steven Schveighoffer wrote: Your best bet is to free the memory itself if it's possible. import core.memory: GC; GC.free(combs.ptr); For

Re: Best properly way to destroy a 2 dimensional array?

2016-04-08 Thread Jonathan Villa via Digitalmars-d-learn
On Thursday, 7 April 2016 at 16:13:59 UTC, Steven Schveighoffer wrote: On 4/6/16 3:54 PM, Jonathan Villa wrote: You are likely running into the GC being conservative. You are also possibly running into an issue where you are expecting the compiler to do something with the stack where it may

Re: Best properly way to destroy a 2 dimensional array?

2016-04-07 Thread Jonathan Villa via Digitalmars-d-learn
On Thursday, 7 April 2016 at 10:05:02 UTC, Andrea Fontana wrote: On Thursday, 7 April 2016 at 10:02:05 UTC, Andrea Fontana wrote: On Wednesday, 6 April 2016 at 20:30:33 UTC, Jonathan Villa wrote: Anything change if you wrap your code like: while ... { ... { ubyte[][] ... ...

Re: Best properly way to destroy a 2 dimensional array?

2016-04-06 Thread Jonathan Villa via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 21:33:14 UTC, Alex Parrill wrote: On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a ... Why not make a range instead? No need to reserve memory for the entire array if you can compute

Re: Best properly way to destroy a 2 dimensional array?

2016-04-06 Thread Jonathan Villa via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a TL;DR: My program generates a very large `ubyte[][]`, and after I call destroy and GC.collect() and GC.minimize(), the memory occuping doesn't seems to decrease.

Re: Best properly way to destroy a 2 dimensional array?

2016-04-06 Thread Jonathan Villa via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a list of different combinations (represented by a ubyte array), so in the end my function with name GenerateCombinations(int x) returns a ubyte[][] (list of arrays of

Best properly way to destroy a 2 dimensional array?

2016-04-06 Thread Jonathan Villa via Digitalmars-d-learn
I wrote a little program that given some number it generates a list of different combinations (represented by a ubyte array), so in the end my function with name GenerateCombinations(int x) returns a ubyte[][] (list of arrays of ubytes). Now the problem is, the quantity of combinations

Re: Strange behavior in console with UTF-8

2016-03-28 Thread Jonathan Villa via Digitalmars-d-learn
On Monday, 28 March 2016 at 18:28:33 UTC, Steven Schveighoffer wrote: On 3/27/16 12:04 PM, Jonathan Villa wrote: I can reproduce your issue on windows. It works on Mac OS X. I see different behavior on 32-bit (DMC stdlib) vs. 64-bit (MSVC stdlib). On both, the line is not read properly (I

Re: Strange behavior in console with UTF-8

2016-03-27 Thread Jonathan Villa via Digitalmars-d-learn
On Saturday, 26 March 2016 at 16:34:34 UTC, Steven Schveighoffer wrote: On 3/25/16 6:47 PM, Jonathan Villa wrote: At this point, I think knowing exactly what input you are sending would be helpful. Can you attach a file which has the input that causes the error? Or just paste the input into

Re: Strange behavior in console with UTF-8

2016-03-27 Thread Jonathan Villa via Digitalmars-d-learn
On Saturday, 26 March 2016 at 16:34:34 UTC, Steven Schveighoffer wrote: On 3/25/16 6:47 PM, Jonathan Villa wrote: On Friday, 25 March 2016 at 13:58:44 UTC, Steven Schveighoffer wrote: [...] OK, the following inputs I've tested: á, é, í, ó, ú, ñ, à, è, ì, ò, ù. Just one input is enough to

Re: Strange behavior in console with UTF-8

2016-03-25 Thread Jonathan Villa via Digitalmars-d-learn
On Friday, 25 March 2016 at 13:58:44 UTC, Steven Schveighoffer wrote: On 3/24/16 8:54 PM, Jonathan Villa wrote: [...] D's File i/o uses C's FILE * i/o system. At least on Windows, this has literally zero support for wchar (you can set stream width, and the library just ignores it). What

Re: Strange behavior in console with UTF-8

2016-03-24 Thread Jonathan Villa via Digitalmars-d-learn
On Friday, 25 March 2016 at 01:03:06 UTC, Ali Çehreli wrote: > Try char: char[] readerBuffer; Ali Also tried with dchar ... there's no changes.

Re: Strange behavior in console with UTF-8

2016-03-24 Thread Jonathan Villa via Digitalmars-d-learn
On Friday, 25 March 2016 at 01:03:06 UTC, Ali Çehreli wrote: On 03/24/2016 05:54 PM, Jonathan Villa wrote: Try char: char[] readerBuffer; flush() has no effect on input streams. Ali Thankf fot he quick reply. Unfortunately it behaves exactly as before with wchar.

Strange behavior in console with UTF-8

2016-03-24 Thread Jonathan Villa via Digitalmars-d-learn
I prefer to post this thing here because it could that I'm doing something wrong. I'm using std.stdio -> readln() to read whatever I'm typing in the console. BUT, if the line contains some UTF-8 characters, the data obtained is EMPTY and module runnable; import std.stdio; import

issue importing std.file or std.stdio on win x64 build.

2015-12-02 Thread Jonathan Villa via Digitalmars-d-learn
Hello, I've been trying to program and app that writes its own log, so, to deal with files I tried using std.file. But with just adding the import std.file; it throws me (AFAIK) a link error: (some texts are in spanish, I tried to translate the important thing) Building Release\ASI.exe...

Re: need help with Windows CreateNamedPipe Security attributes process with undefined symbols at compile time

2015-12-01 Thread Jonathan Villa via Digitalmars-d-learn
On Tuesday, 1 December 2015 at 14:48:37 UTC, Adam D. Ruppe wrote: On Tuesday, 1 December 2015 at 14:40:38 UTC, Jonathan Villa wrote: MAN! what the heck? I changed the build from x86 to x64 and there's no more errors. Even without the new pragma line. Either way I would prefer x64 over x86.

Re: need help with Windows CreateNamedPipe Security attributes process with undefined symbols at compile time

2015-12-01 Thread Jonathan Villa via Digitalmars-d-learn
On Tuesday, 1 December 2015 at 05:26:25 UTC, Nicholas Wilson wrote: What is causing this: Is this a compile or a linker error? this is the real output of the error: Building Debug\ASI.exe... OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved.

need help with Windows CreateNamedPipe Security attributes process with undefined symbols at compile time

2015-11-30 Thread Jonathan Villa via Digitalmars-d-learn
Hi, I've been trying to create a NamedPipe with security attributes but at compile time throws: Error 42: Symbol Undefined _InitializeSecurityDescriptor@8 Error 42: Symbol Undefined _SetSecurityDescriptorDacl@16 This is my code, I'm trying to do it using a class: module asi.pipe; import

Re: compilation issues in a shared library project

2015-06-15 Thread Jonathan Villa via Digitalmars-d-learn
On Monday, 15 June 2015 at 06:39:49 UTC, Nicholas Wilson wrote: On Sunday, 7 June 2015 at 00:38:17 UTC, Jonathan Villa wrote: Just an FYI classes are reference types in D so you probably meant public DataBlock NextBlock; // is a class reference public DataBlock * PrevBlock;

Re: compilation issues in a shared library project

2015-06-14 Thread Jonathan Villa via Digitalmars-d-learn
On Tuesday, 9 June 2015 at 14:30:24 UTC, Benjamin Thaut wrote: Shared libraries (DLLs) don't work on windows. They only work for the simplest of all cases (e.g. global functions) and even then there are pitfalls. Just don't do it. The only viable option currently is to link statically or put