Re: Understanding SIGSEGV issues

2019-01-02 Thread Nicholas Wilson via Digitalmars-d-learn

On Thursday, 3 January 2019 at 06:25:46 UTC, Russel Winder wrote:
So I have a D program that used to work. I come back to it, 
recompile it, and:


[...]



__GI___libc_free (mem=0xa) at malloc.c:3093


You've tried to free a pointer that, while not null, was derived 
from a pointer that was, i.e. an offset to a field of a struct.


A backtrace would help a lot, otherwise it really is just 
guessing.


Understanding SIGSEGV issues

2019-01-02 Thread Russel Winder via Digitalmars-d-learn
So I have a D program that used to work. I come back to it, recompile it, and:

|> dub run -- ~/lib/DigitalTelevision/DVBv5/uk-CrystalPalace__RW 
Performing "debug" build using /usr/bin/ldc2 for x86_64.
libdvbv5_d 0.1.1: target for configuration "library" is up to date.
dvb-tune ~master: target for configuration "application" is up to date.
To force a rebuild of up-to-date targets, run again with --force.
Running ./bin/dvb-tune 
/home/users/russel/lib/DigitalTelevision/DVBv5/uk-CrystalPalace__RW
Device: Silicon Labs Si2168, adapter  0, frontend  0
Program exited with code -11

(gdb) r ~/lib/DigitalTelevision/DVBv5/uk-CrystalPalace__RW
Starting program: 
/home/users/russel/Repositories/Git/Masters/Public/DVBTune/bin/dvb-tune 
~/lib/DigitalTelevision/DVBv5/uk-CrystalPalace__RW
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Device: Silicon Labs Si2168, adapter  0, frontend  0

Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0xa) at malloc.c:3093
3093malloc.c: No such file or directory.
(gdb) 

Can anyone give me any hints as to where to start even getting a glimmer of an
understanding of WTF is going on?

-- 
Russel.
===
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



signature.asc
Description: This is a digitally signed message part


Re: Vibe.d throw link error

2019-01-02 Thread Me via Digitalmars-d-learn

On Thursday, 3 January 2019 at 00:23:50 UTC, greatsam4sure wrote:

On Wednesday, 2 January 2019 at 21:46:57 UTC, bauss wrote:


Error: linker exit with status 1
Dmd failed  with exit code 1


This is all the compiler emit


Windows 10 --- got it
VibeD project --- got it
Error --- got it

What exactly were you trying to do? What you have given so far 
offers no incite. Try providing a bit more information, offending 
code, cli command and associated arguments used, etc...


Re: Vibe.d throw link error

2019-01-02 Thread greatsam4sure via Digitalmars-d-learn

On Wednesday, 2 January 2019 at 21:46:57 UTC, bauss wrote:


Error: linker exit with status 1
Dmd failed  with exit code 1


This is all the compiler emit


Vibe.d throw link error

2019-01-02 Thread greatsam4sure via Digitalmars-d-learn
I am using windows 10. I could not run vibe project. It just give 
me the error:


Error: linker exit with status 1
Dmd failed  with exit code 1

I have use different dmd from 0.080 till 0.083. The same error.

What is the possible cause and solution to this error?


Re: Two questions

2019-01-02 Thread IM via Digitalmars-d-learn

On Wednesday, 2 January 2019 at 17:49:52 UTC, H. S. Teoh wrote:
On Wed, Jan 02, 2019 at 05:38:41PM +, IM via 
Digitalmars-d-learn wrote:

1- How do I do in D the equivalent of the following C++ macro?

#define OUT_VAL(val) (count << #val << " = " << val << endl)

In particular the #val above to the actual macro argument as a 
string?

[...]

Try something along these lines:

import std.stdio;
void OUT_VAL(alias val)() {
writefln("%s = %s", __traits(identifier, val), val);
}
void main() {
int i = 123;
string s = "abc";
OUT_VAL!i;
OUT_VAL!s;
}


T


Thank you so much. Will give this a try.


Re: Two questions

2019-01-02 Thread IM via Digitalmars-d-learn
On Wednesday, 2 January 2019 at 21:56:03 UTC, Steven 
Schveighoffer wrote:

On 1/2/19 12:38 PM, IM wrote:


[...]


With those ... I have to guess.

There are 2 possibilities.

Possibility 1: there is a method named 'doSomeWork' which takes 
at least one parameter. This overrides the UFCS function 
(member functions always win over UFCS).


Possibility 2: All this is actually inside a function or 
unittest. Nested functions cannot participate in UFCS.




Perfect, this was it. Thank you so much. doSomeWork() was nested 
inside a unittest{} block. I didn't know UFCS won't work in this 
case.


Of course, these are guesses. But given the very scant code 
above, I'm not sure I could offer any other suggestions. If 
neither of those is the case, I'd need a working example.


-Steve




Re: Two questions

2019-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/2/19 12:38 PM, IM wrote:

2- Yesterday I was experimenting with something and I wrote something 
like the following:


struct MyType {
   ...
}

void doSomeWork(ref MyType o) {
    ...
}

auto t = MyType(...);

t.doSomeWork(); // <-- failed to compile.

Why did the above UFCS call fail to compile? I had to do doSomeWork(t) 
instead.


With those ... I have to guess.

There are 2 possibilities.

Possibility 1: there is a method named 'doSomeWork' which takes at least 
one parameter. This overrides the UFCS function (member functions always 
win over UFCS).


Possibility 2: All this is actually inside a function or unittest. 
Nested functions cannot participate in UFCS.


Of course, these are guesses. But given the very scant code above, I'm 
not sure I could offer any other suggestions. If neither of those is the 
case, I'd need a working example.


-Steve


Re: Vibe.d throw link error

2019-01-02 Thread bauss via Digitalmars-d-learn

On Wednesday, 2 January 2019 at 20:52:26 UTC, greatsam4sure wrote:
I am using windows 10. I could not run vibe project. It just 
give me the error:


Error: linker exit with status 1
Dmd failed  with exit code 1

I have use different dmd from 0.080 till 0.083. The same error.

What is the possible cause and solution to this error?


Some more information would be useful.

Compiler flags, dub configuration and OS.


Vibe.d throw link error

2019-01-02 Thread greatsam4sure via Digitalmars-d-learn
I am using windows 10. I could not run vibe project. It just give 
me the error:


Error: linker exit with status 1
Dmd failed  with exit code 1

I have use different dmd from 0.080 till 0.083. The same error.

What is the possible cause and solution to this error?


Two questions

2019-01-02 Thread IM via Digitalmars-d-learn

1- How do I do in D the equivalent of the following C++ macro?

#define OUT_VAL(val) (count << #val << " = " << val << endl)

In particular the #val above to the actual macro argument as a 
string?


2- Yesterday I was experimenting with something and I wrote 
something like the following:


struct MyType {
  ...
}

void doSomeWork(ref MyType o) {
   ...
}

auto t = MyType(...);

t.doSomeWork(); // <-- failed to compile.

Why did the above UFCS call fail to compile? I had to do 
doSomeWork(t) instead.


Thank you so much!


Re: Weird combo of static function, templates, interfaces (that doesn't link)

2019-01-02 Thread 0xEAB via Digitalmars-d-learn

On Sunday, 30 December 2018 at 18:55:10 UTC, Ali Çehreli wrote:

On 12/30/2018 05:05 AM, 0xEAB wrote:

>> interface FooAdapter
>> {
>> FooBundle!(Handle) createSome(Handle)();
>> }

Function templates cannot be virtual functions. One reason is 
the compiler cannot know how large the virtual function table 
should be, and the other one is it's just a template, not the 
real thing (i.e. not a function).


>> private class SomeAdapter : FooAdapter
>> {
>> Bundle createSome()

SomeAdapter.createSome is a function unrelated to 
FooAdapter.createSome. Their only relationship is through "name 
hiding."


> - Does `SomeAdapter` even implement `FooAdapter` correctly?

Yes because FooAdapter has no virtual function. :p

>   ~ Elias

Ali


Thanks for the technical explanation.
  ~ Elias


Re: D-oriented Syntax Highlighting Plugin for WordPress?

2019-01-02 Thread Ron Tarrant via Digitalmars-d-learn

On Wednesday, 2 January 2019 at 02:09:11 UTC, Mike Parker wrote:


It supports D out of the box.
Thanks, Mike. Once I downloaded it and dug around, I found the 
list of supported languages. Odd they don't list these on the 
about page or wherever.





Re: Low order hashes

2019-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/1/19 2:40 PM, Michelle Long wrote:
I need to hash a few strings to a byte, short, or int. hashOf works for 
int only on x86.


What would be a nice way to accomplish this? Collisions are not good but 
not catastrophic. Mainly I need a unique ID to emulate enums. I might 
just chop off the extra bits or mash them up somehow and it will 
probably work but hoping for something more solid.




Not from experience, but just thinking out loud, you could take the int 
and xor the parts together.


in other words:

auto x = hashOf(y);
ushort realHash = (x ^ (x >> 16)) & 0x;

ubyte would be 4 terms, but still not too bad.

-Steve