Re: Where are declared and how to make build these c identifiers?

2019-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sat, Feb 23, 2019 at 09:53:09PM -0300, Cleverson Casarin Uliana via 
Digitalmars-d-learn wrote:
> OK, do I need to install the entire arsd package? I've saved the terminal.d
> file on an arsd directory I've just created inside the import directory, but
> trying to build it gives me lots of undefined symbol errors.

You just need to pass the terminal.d file to your build too.

dmd yourfile.d terminal.d

so it knows to include it.

> I want a generic function that returns what key I have pressed, including
> keys like the arrows, so I can for example play a sound on a given key
> press. If the method is portable among Windows, Linux and others, so better.

Yeah, terminal.d can do that, I don't remember if the getch function 
specifically
handles arrows... I think it does though, but I know for sure the other 
functions
do (you can do a full event loop with it)

> BTW, although not strictly on topic, I'd also apreciate portable functions
> to play and stop sounds assynchronously, similar to PlaySound on Windows...

so i have that but i'm not happy with it and it isn't documented...



Re: Where are declared and how to make build these c identifiers?

2019-02-23 Thread Cleverson Casarin Uliana via Digitalmars-d-learn

Hi Adam, many thanks for all informations. To answer your questions:

Em 23/02/2019 20:08, Adam D. Ruppe via Digitalmars-d-learn escreveu:
I would suggest using different functions... like my terminal.d 
library which 
has similar api (see example: 
http://dpldocs.info/experimental-docs/arsd.terminal.html#single-key )


OK, do I need to install the entire arsd package? I've saved the 
terminal.d file on an arsd directory I've just created inside the import 
directory, but trying to build it gives me lots of undefined symbol errors.


Admittedly, I haven't yet learned how to deal with D packages, so maybe 
I should do just that.


> What do you need the program to actually do?

I want a generic function that returns what key I have pressed, 
including keys like the arrows, so I can for example play a sound on a 
given key press. If the method is portable among Windows, Linux and 
others, so better.


BTW, although not strictly on topic, I'd also apreciate portable 
functions to play and stop sounds assynchronously, similar to PlaySound 
on Windows...


Greetings,
Cleverson


Re: Odd behavior of darray.dup

2019-02-23 Thread solidstate1991 via Digitalmars-d-learn
On Saturday, 23 February 2019 at 19:21:10 UTC, Bastiaan Veelo 
wrote:


It works for me:
https://run.dlang.io/gist/473b0021487275751accaebeb00be05c

-- Bastiaan


Still no luck, not even with memcpy.

There's even more mystery as I printed out the original static 
immutable array's content, which is different from the 
non-immutable one. Instead of the 32bit hex value of the given 
color in the format of "0x", I get 
"immutable(Color)(#{overlap raw, colors})". This might be a bug.


Re: Where are declared and how to make build these c identifiers?

2019-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 23 February 2019 at 21:10:19 UTC, Cleverson Casarin 
Uliana wrote:
However, I'd like to know how all these functions really work, 
so I'd like to know where they are declared and/or defined.


Those functions are extensions from the Digital Mars C runtime 
library (inspired by something Borland offered back in the day).


Only real docs for them are here: 
https://digitalmars.com/rtl/conio.html


The STI_conio one isn't documented, I think that is the internal 
initializer function, and STD_conio is the destructor function.



lld-link: error: undefined symbol: _STD_conio
>>> referenced by keypress.obj:(_Dmain)


Those functions are only present in the DMC library, which is 
only used when using `dmd` to make a 32 bit build on Windows (and 
even then, only if you do NOT use `-m32mscoff`).


I would suggest using different functions... like my terminal.d  
library which has similar api (see example: http://dpldocs.info/experimental-docs/arsd.terminal.html#single-key )


What do you need the program to actually do?


Re: template alias argument accepts only class/interface types.

2019-02-23 Thread ag0aep6g via Digitalmars-d-learn

On 23.02.19 23:30, Alexandru Ermicioi wrote:
According to 
https://dlang.org/spec/template.html#TemplateAliasParameter, simple 
types and arrays are excluded from the list of supported "alias X" 
arguments. I'm wondering why do we have such limitation? Is there any 
reasoning at limiting primitive types and arrays?


As far as I'm aware, there is no good reason. There's a Bugzilla issue 
for it that also gives some history:


https://issues.dlang.org/show_bug.cgi?id=9029

Apparently even Walter has been convinced by now that it's a silly 
limitation which should be lifted.


template alias argument accepts only class/interface types.

2019-02-23 Thread Alexandru Ermicioi via Digitalmars-d-learn
Perhaps I missed somewhere, but it seems that you can pass only 
classes or interfaces to alias argument of a template. Trying to 
pass another type (such as int, int[]) yields an error.


Example of issue:

void test(alias T)(int o) {
import std.stdio;
writeln("coo");
}

void main() {
int i;
test!(Object[])(0);
}


Try pass Object or IFoo and everything compiles perfectly.
Link to example: https://run.dlang.io/is/jqr9Zi

According to 
https://dlang.org/spec/template.html#TemplateAliasParameter, 
simple types and arrays are excluded from the list of supported 
"alias X" arguments. I'm wondering why do we have such 
limitation? Is there any reasoning at limiting primitive types 
and arrays?


Thank you,
Alexandru.



Re: Process Information

2019-02-23 Thread Cym13 via Digitalmars-d-learn

On Saturday, 23 February 2019 at 20:49:49 UTC, r-const-dev wrote:

Is there a way to get information about the current process?
Memory usage, CPU usage, PID.


The PID is easy, from std.process it's a standard function call 
away: https://dlang.org/phobos/std_process.html#.thisProcessID


I don't think there is anything in phobos about memory or cpu 
usage. If you're on GNU/Linux you can probe /proc/self/stat and 
/proc/self/status to get that information, I don't know about 
windows.


Where are declared and how to make build these c identifiers?

2019-02-23 Thread Cleverson Casarin Uliana via Digitalmars-d-learn
Hi all, I'm revisiting D after some years. I'd like to test a code 
snipped from RosettaCode, which is suposed to check a key press, as follows:


extern (C) {
void _STI_conio();
void _STD_conio();
int kbhit();
int getch();
}

void main() {
_STI_conio();
char c;
if (kbhit())
c = cast(char)getch();
_STD_conio();
}

However, I'd like to know how all these functions really work, so I'd 
like to know where they are declared and/or defined. Since there are 
that extern (C) line at the beginning of the snippet, I assume them to 
be c code, so my question is, is there any kinda C library refference 
where I can find such declarations, similar to the Phobos library 
refference in D? In principle, I couldn't find e.g. _sti_conio by 
searching on Google.


In addition, I went to try building the code above with:
ldc2 -release -Os keypress.d
but received this error message:
lld-link: error: undefined symbol: _STI_conio
>>> referenced by keypress.obj:(_Dmain)


lld-link: error: undefined symbol: _STD_conio
>>> referenced by keypress.obj:(_Dmain)

Error: linking with LLD failed

As far as I recall, such kind of error indicates a library is missing on 
the command line. Does anyone know what it is please?


Thanks for your help,
Cleverson


Process Information

2019-02-23 Thread r-const-dev via Digitalmars-d-learn

Is there a way to get information about the current process?
Memory usage, CPU usage, PID.


Re: Odd behavior of darray.dup

2019-02-23 Thread Bastiaan Veelo via Digitalmars-d-learn

On Friday, 22 February 2019 at 11:36:35 UTC, solidstate1991 wrote:
If I want to copy an array of structs with .dup (cannot post 
the link in question here at the moment due to non-working 
clipboard, it's Color from pixelperfectengine.graphics.common) 
I get all zeroes instead of the values from the original array. 
I haven't disabled post-blit to my knowledge.


Is it some kind of a bug, or the .dup function has some 
behavior that's not currently documented on the site (such as 
needing a copy constructor)?


It works for me:
https://run.dlang.io/gist/473b0021487275751accaebeb00be05c

-- Bastiaan


Re: Has anyone tried making a QtCreator plugin for D and what is your experience?

2019-02-23 Thread Mirjam Akkersdijk via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 21:51:57 UTC, Laurent Tréguier 
wrote:

On Saturday, 12 January 2019 at 20:10:40 UTC, Enjoys Math wrote:
On Saturday, 12 January 2019 at 16:09:22 UTC, Laurent Tréguier 
wrote:
On Saturday, 12 January 2019 at 15:16:25 UTC, Laurent 
Tréguier wrote:
QtCreator 4.8.0 introduced support for the LSP last month : 
https://blog.qt.io/blog/2018/12/06/qt-creator-4-8-0-released


I think I'm going to add it to the list of editors to look 
into and perhaps try to make a plugin for it.


Correction: a language server can simply be set up in the LSP 
plugin's options after the plugin has been enabled, so some 
amount of D support is achievable already.


I see your links. Would you like to work on this together?  
Social coding is more powerful than solo coding IMO.


Is it necessary to make a plugin though ? Syntax highlighting 
can be downloaded directly through QtCreator's syntax options, 
and then the new bundled LSP plugin can be configured directly 
to use any language server.


As an avid C++ programmer I preferably work in QtCreator, though 
my heart really tends toward D, for which I usually just use 
plain old vim.


https://blog.qt.io/blog/2019/02/21/qt-creator-4-9-beta-released/

With the new version, they seem to improve on the LSP which they 
introduced in the current version of 4.8. Has anyone tried it 
yet? I would switch in a beat if it has full D support.