Floating point literal definition

2016-02-29 Thread ric maicle via Digitalmars-d-learn

I'm currently reading about floating point literal and came to this
part:

FloatLiteral:
...
Integer ImaginarySuffix
Integer FloatSuffix ImaginarySuffix
Integer RealSuffix ImaginarySuffix

Going to the Integer link, it is defined as:

Integer:
...
BinaryInteger

and BinaryInteger is defined as:

BinaryInteger:
BinPrefix BinaryDigitsUS

This program produces the error: semicolon expected, not 'b01f'.

void main()
{
double d = 0b01f;
}

So, does D allow floating point literals in binary format or not?
If not then the floating point literal definition is a bit misleading.
Or maybe someone had already filed a bug report on this?


Re: Member Access Based On A Runtime String

2016-02-29 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 1 March 2016 at 05:05:40 UTC, Jack Stouffer wrote:

In Python, I can do this:

my_obj = Obj()
string_from_func = func()
setattr(my_obj, string_from_func, 100)

Say func() returns "member1" or "member2", the setattr would 
then set either one of those to 100.


Is there any equivalent in D?


Not built-in. You would have do something similar to what the 
Python interpreter does. Store  pointers to the setter functions 
in an AA and use the member names as keys.


Re: ErrnoException

2016-02-29 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote:



Ok, that would throw some OOM exception instead so I wouldn't 
need to bother with it, is there something else in the GC that 
would override it during class instance allocation? I am 
finding it weird that ErrnoException doesn't let you specify 
the errno value explicitly, you usually check it in your code 
anyway (e.g. for EINTR and repeat the operation and not throw 
this error).


An additional constructor that accepts and errno value sounds 
like a good potential PR.


Re: Backslash escaping weirdness

2016-02-29 Thread Nicholas Wilson via Digitalmars-d-learn

On Tuesday, 1 March 2016 at 04:48:01 UTC, Adam D. Ruppe wrote:

On Tuesday, 1 March 2016 at 04:18:11 UTC, Nicholas Wilson wrote:
What is causing these errors? I'm using \t and \n in string 
all over the place and they work.


I don't think there's enough context to know for sure... but my 
guess is you forgot to close one of the quotes a couple lines 
above.


So look up for an unpaired "


It was. Thanks.


Member Access Based On A Runtime String

2016-02-29 Thread Jack Stouffer via Digitalmars-d-learn

In Python, I can do this:

my_obj = Obj()
string_from_func = func()
setattr(my_obj, string_from_func, 100)

Say func() returns "member1" or "member2", the setattr would then 
set either one of those to 100.


Is there any equivalent in D?


Re: Backslash escaping weirdness

2016-02-29 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 1 March 2016 at 04:18:11 UTC, Nicholas Wilson wrote:
What is causing these errors? I'm using \t and \n in string all 
over the place and they work.


I don't think there's enough context to know for sure... but my 
guess is you forgot to close one of the quotes a couple lines 
above.


So look up for an unpaired "


Backslash escaping weirdness

2016-02-29 Thread Nicholas Wilson via Digitalmars-d-learn

line 620:
for(auto i = 1; i < pits3.length - 2; i++)
 {
  f.write(params3[i].fixup_T,"\t", pits3[i],",");
}
f.write(params3[$-2].fixup_T,"\t", pits3[$-1]);
f.write(")\n\t\t{typeof(return) _p;\n\t\t", m2,"(",mainVarName);
for(auto i = 1; i < pits3.length - 2; i++)
{
  f.write(",",pits3[i]);
}
f.write(",&_p);\n\t\treturn _p;}");

params3 and pits3 are both string[]s length equal and length > 3
fixup_T is a string function(string)

gives a bunch of errors
source/app.d(622): Error: character '\' is not a valid token
source/app.d(622): Error: found 't' when expecting ','
source/app.d(624): Error: character '\' is not a valid token
source/app.d(624): Error: found 't' when expecting ','
source/app.d(625): Error: character '\' is not a valid token
source/app.d(625): Error: found 'n' when expecting ';' following 
statement

source/app.d(625): Error: character '\' is not a valid token
source/app.d(625): Error: character '\' is not a valid token
source/app.d(625): Error: semicolon expected, not '{'
source/app.d(625): Error: character '\' is not a valid token
source/app.d(625): Error: character '\' is not a valid token
source/app.d(625): Error: character '\' is not a valid token
source/app.d(625): Error: found 't' when expecting ';' following 
statement
source/app.d(625): Error: found '", m2,"' when expecting ';' 
following statement

source/app.d(630): Error: character '\' is not a valid token
source/app.d(630): Error: character '\' is not a valid token
source/app.d(630): Error: character '\' is not a valid token
source/app.d(630): Error: found 't' when expecting ';' following 
statement

source/app.d(637): Error: character '\' is not a valid token
source/app.d(637): Error: found 'n' when expecting ';' following 
statement


What is causing these errors? I'm using \t and \n in string all 
over the place and they work.

$dmd
DMD64 D Compiler v2.070-devel-5123284



Inline assembly and Profiling

2016-02-29 Thread Matthew Dudley via Digitalmars-d-learn
I'm working on a chess engine side-project, and I'm starting to 
get into profiling and optimization.


One of the optimizations I've made involves some inline assembly, 
and I ran across some apparently bizarre behavior today, and I 
just wanted to double-check that I'm not doing something wrong.


Here's the behavior boiled down:

import std.stdio;
ubyte LS1B(ulong board)
{
  asm
  {
bsf RAX, board;
  }
}

void main()
{
  auto one = 0x939839FA;
  assert(one.LS1B == 1, "Wrong LS1B!");
}

If I run this through DMD without profiling on, it runs 
successfully, but with profiling on, the assertion fails. And in 
the actual code, it returns seeming random numbers.


Is the profiling code stomping on my toes here? Am I not allowed 
to just single instruction into RAX like this with profiling on? 
Or is this just a compiler bug?





Re: ErrnoException

2016-02-29 Thread Jirka via Digitalmars-d-learn

On Monday, 29 February 2016 at 23:41:51 UTC, Chris Wright wrote:

On Mon, 29 Feb 2016 21:55:49 +, Jirka wrote:

Yes, that I understand, but the "new" operator can lead to 
other system calls (?), could they overwrite it?


Yes. Most obviously, the GC uses malloc, which will set errno 
to ENOMEM on failure.


Ok, that would throw some OOM exception instead so I wouldn't 
need to bother with it, is there something else in the GC that 
would override it during class instance allocation? I am finding 
it weird that ErrnoException doesn't let you specify the errno 
value explicitly, you usually check it in your code anyway (e.g. 
for EINTR and repeat the operation and not throw this error).


Re: ErrnoException

2016-02-29 Thread Chris Wright via Digitalmars-d-learn
On Mon, 29 Feb 2016 21:55:49 +, Jirka wrote:

> Yes, that I understand, but the "new" operator can lead to other system
> calls (?), could they overwrite it?

Yes. Most obviously, the GC uses malloc, which will set errno to ENOMEM 
on failure.


Re: D equivalent of run-time DLLs / Plugins

2016-02-29 Thread Ali Çehreli via Digitalmars-d-learn

On 02/29/2016 02:40 PM, Chris Katko wrote:


I want
to link to piece of D code at run-time. I want my D program to load,
scan for files which are whatever D-equivalent of a DLL/SO is, and load
those as well. Calling library functions, and having them call my core
functions.


It's the same as in C. Assuming that you have a ./libxyz.so that 
contains library_function() of type 'int library_func(int)', the 
following works:


import std.stdio;
import core.sys.linux.dlfcn;

extern(C) int library_func(int);
alias FuncType = int function(int);

int main()
{
void * lib = dlopen("./libxyz.so", RTLD_NOW);

if (!lib) {
stderr.writefln("Failed to open library");
return 1;
}

auto func = cast(FuncType)dlsym(lib, "library_func");

if (!func) {
stderr.writefln("Failed to find function");
return 1;
}

writefln("Result: %s", func(10));

return 0;
}

Ali



Re: D equivalent of run-time DLLs / Plugins

2016-02-29 Thread Chris Katko via Digitalmars-d-learn

On Monday, 29 February 2016 at 22:12:37 UTC, jmh530 wrote:

On Monday, 29 February 2016 at 19:02:27 UTC, Chris Katko wrote:

Hello. Dlang newbie here.

Does D support run-time loading of D modules?

Basically, I'm looking to create an application with a plugin 
interface.


I've seen a few posts, but they're dated and it's hard to keep 
up with "What is the proper way to do X" when things change 
rapidly. Last thing I want to do is retread ground when 
someone else already has a more elegant solution.


Also, are there any features to avoid that will cause 
problems? I don't plan on needing anything too fancy.


Thanks.


Mike Parker's book covers the subject
https://www.packtpub.com/application-development/learning-d

That part of the book closely follows a series he wrote on 
gamedev (there's more than just that post)

http://www.gamedev.net/page/resources/_/technical/game-programming/binding-d-to-c-r3122


I'm confused. Both posts appear to be for linking D to C++ DLLs. 
I want to link to piece of D code at run-time. I want my D 
program to load, scan for files which are whatever D-equivalent 
of a DLL/SO is, and load those as well. Calling library 
functions, and having them call my core functions.


Re: D equivalent of run-time DLLs / Plugins

2016-02-29 Thread jmh530 via Digitalmars-d-learn

On Monday, 29 February 2016 at 19:02:27 UTC, Chris Katko wrote:

Hello. Dlang newbie here.

Does D support run-time loading of D modules?

Basically, I'm looking to create an application with a plugin 
interface.


I've seen a few posts, but they're dated and it's hard to keep 
up with "What is the proper way to do X" when things change 
rapidly. Last thing I want to do is retread ground when someone 
else already has a more elegant solution.


Also, are there any features to avoid that will cause problems? 
I don't plan on needing anything too fancy.


Thanks.


Mike Parker's book covers the subject
https://www.packtpub.com/application-development/learning-d

That part of the book closely follows a series he wrote on 
gamedev (there's more than just that post)

http://www.gamedev.net/page/resources/_/technical/game-programming/binding-d-to-c-r3122


Re: ErrnoException

2016-02-29 Thread Jirka via Digitalmars-d-learn

On Sunday, 28 February 2016 at 14:59:22 UTC, Mike Parker wrote:

On Sunday, 28 February 2016 at 13:10:20 UTC, Jirka wrote:
I have a question about ErrnoException. When I throw it (throw 
new ErrnoException()), won't it overwrite the errno value 
before it can capture it?


Its constructor [1] simply fetches the current errno and gets 
an error message from it.


[1] 
https://github.com/D-Programming-Language/phobos/blob/master/std/exception.d#L1491


Yes, that I understand, but the "new" operator can lead to other 
system calls (?), could they overwrite it?


Re: Initialize associate array

2016-02-29 Thread Adam D. Ruppe via Digitalmars-d-learn

Use a constructor instead.


Re: Initialize associate array

2016-02-29 Thread cym13 via Digitalmars-d-learn

On Monday, 29 February 2016 at 21:03:46 UTC, pham wrote:

Should codes below be compiled?

import std.stdio;

class Test
{
enum string[string] WorkAA =
[
"foo": "work"
];

immutable string[string] NotWorkAA1 =
[
"foo": "not work"
];

string[string] NotWorkAA2 =
[
"foo": "not work"
];
}

void main()
{
Test t = new Test();
}

Test with DPaste with below error messages

Result: Compilation error / Return code: 1 (Hangup)
Compilation output:

/d699/f49.d(11): Error: non-constant expression ["foo":"not 
work"]
/d699/f49.d(16): Error: non-constant expression ["foo":"not 
work"]


According to the specs it should but right now it doesn't, it's a 
know long-lasting bug. AA can't be initialized at compile-time 
for the moment (and likely not before a long time).


Initialize associate array

2016-02-29 Thread pham via Digitalmars-d-learn

Should codes below be compiled?

import std.stdio;

class Test
{
enum string[string] WorkAA =
[
"foo": "work"
];

immutable string[string] NotWorkAA1 =
[
"foo": "not work"
];

string[string] NotWorkAA2 =
[
"foo": "not work"
];
}

void main()
{
Test t = new Test();
}

Test with DPaste with below error messages

Result: Compilation error / Return code: 1 (Hangup)
Compilation output:

/d699/f49.d(11): Error: non-constant expression ["foo":"not work"]
/d699/f49.d(16): Error: non-constant expression ["foo":"not work"]



Re: D equivalent of run-time DLLs / Plugins

2016-02-29 Thread Carsten Blüggel via Digitalmars-d-learn

On Monday, 29 February 2016 at 19:02:27 UTC, Chris Katko wrote:

Hello. Dlang newbie here.

Does D support run-time loading of D modules?

Basically, I'm looking to create an application with a plugin 
interface.


I've seen a few posts, but they're dated and it's hard to keep 
up with "What is the proper way to do X" when things change 
rapidly. Last thing I want to do is retread ground when someone 
else already has a more elegant solution.


Also, are there any features to avoid that will cause problems? 
I don't plan on needing anything too fancy.


Thanks.


Sounds like You are looking for package 
https://code.dlang.org/packages/derelict-util

and adjust to Your needs.


D equivalent of run-time DLLs / Plugins

2016-02-29 Thread Chris Katko via Digitalmars-d-learn

Hello. Dlang newbie here.

Does D support run-time loading of D modules?

Basically, I'm looking to create an application with a plugin 
interface.


I've seen a few posts, but they're dated and it's hard to keep up 
with "What is the proper way to do X" when things change rapidly. 
Last thing I want to do is retread ground when someone else 
already has a more elegant solution.


Also, are there any features to avoid that will cause problems? I 
don't plan on needing anything too fancy.


Thanks.


Re: Assoc Array for Concurrency

2016-02-29 Thread ZombineDev via Digitalmars-d-learn

On Monday, 29 February 2016 at 12:43:39 UTC, Chris wrote:
What's the best way to make an assoc array fit for 
multi-threading? If this is not possible what would be the best 
alternative?


Say, for example, `data` is used by a class that is globally 
accessible to all threads. E.g. like this:


string[string] data;  // defined somewhere

public string getData(string key)
{
  if (key in data)
return data[key];
  else
return "";
}


I'm almost sure that built-in AAs don't provide automatic 
synchronization (in my tests I hit a deadlock), but you can 
easily wrap the AA into a struct that does the necessary 
synchronization. However be aware that even then you are not 
going to be safe, because more than one thread can try to access 
the keys or the values of the AA. Also note that because the 
built-in AAs rely on the GC, you may get poor scaling because 
every memory allocation can potentially take the global GC lock, 
which will block all threads from doing any work. So do your own 
tests and if you find the need to improve the performance, I 
would suggest investigating replacing the built-in AA with (for 
example) the hashmap from 
https://github.com/economicmodeling/containers in combination 
with a thread-local allocator.


Here's an example of how to wrap an AA into a moderately safe 
accessor. In the following example I create an additional thread 
which concurrently adds odd numbers into the AA, while the main 
threads add even nubmers:


http://dpaste.dzfl.pl/06025e6374eb

It segfaults on DPaste because you can't create threads there, 
however it works ok on my machine. The output look like this:

"0" : 0.140450140112896
"1" : 1.140450129700608
"2" : 2.140450140112896
"3" : 3.140450129700608
"4" : 4.140450140112896
"5" : 5.140450129700608
"6" : 6.140450140112896
"7" : 7.140450129700608
...


Re: Why we cannot use string in mixins?

2016-02-29 Thread Jesse Phillips via Digitalmars-d-learn

On Sunday, 28 February 2016 at 03:08:14 UTC, mahdi wrote:

Thanks.

So the author was plain wrong about using enums instead of 
strings. The misconception is due to assuming we can use 
`string` variables at compile time but we cannot (as they are 
run-time data).


Not exactly either.

#define str "My string for use"

In C people know the processor which creates a "manifest const." 
In D, it was chosen to reuse enum as the keyword to declare 
manifest const.


enum string str = "My string for use";

But in D, we don't required declaring the type everywhere so you 
can just specify a storage class:


const str = "My string for use";

Combine the things together and you create a compile time string 
without specifying that the type is string.


enum str = "My string for use";



Re: Combining template conditions and contracts?

2016-02-29 Thread Daniel Kozak via Digitalmars-d-learn

auto square_root(T)(T x) if (isBasicType!T)
in
{
assert(x >= 0);
}
out (result)
{
assert((result * result) <= x && (result+1) * (result+1) > x);
}
body
{
return cast(long)std.math.sqrt(cast(real)x);
}

void main()
{
import std.stdio: writeln;
writeln(square_root(2));
}

Dne 29.2.2016 v 15:38 Ozan via Digitalmars-d-learn napsal(a):

Is it possible to combine  template conditions and contracts?
Like in the following


T square_root(T)(T x)  if (isBasicType!T) {
in
{
assert(x >= 0);
}
out (result)
{
assert((result * result) <= x && (result+1) * (result+1) > x);
}
body
{
return cast(long)std.math.sqrt(cast(real)x);
}

Compiler says no. Maybe it's a missunderstanding from my side..

Thanks & regards, Ozan




Re: Combining template conditions and contracts?

2016-02-29 Thread Daniel Kozak via Digitalmars-d-learn



Dne 29.2.2016 v 15:38 Ozan via Digitalmars-d-learn napsal(a):


T square_root(T)(T x)  if (isBasicType!T) {
in
{
assert(x >= 0);
}
out (result)
{
assert((result * result) <= x && (result+1) * (result+1) > x);
}
body
{
return cast(long)std.math.sqrt(cast(real)x);
} 


import std.traits;
import std.math;

template square_root(T) if (isBasicType!T) {
auto square_root(T x)
in
{
assert(x >= 0);
}
out (result)
{
assert((result * result) <= x && (result+1) * (result+1) > x);
}
body
{
return cast(long)std.math.sqrt(cast(real)x);
}
}

void main()
{
import std.stdio: writeln;
writeln(square_root(2));
}




Re: Combining template conditions and contracts?

2016-02-29 Thread Alex Parrill via Digitalmars-d-learn

On Monday, 29 February 2016 at 14:38:52 UTC, Ozan wrote:

Is it possible to combine  template conditions and contracts?
Like in the following


T square_root(T)(T x)  if (isBasicType!T) {
in
{
assert(x >= 0);
}
out (result)
{
assert((result * result) <= x && (result+1) * (result+1) > 
x);

}
body
{
return cast(long)std.math.sqrt(cast(real)x);
}

Compiler says no. Maybe it's a missunderstanding from my side..

Thanks & regards, Ozan


You have a spare { after the template constraint in your sample


Re: Why file.exists of relative path on Linux always return false?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn

On Monday, 29 February 2016 at 14:58:46 UTC, Alex Parrill wrote:

On Monday, 29 February 2016 at 14:50:51 UTC, Suliman wrote:

I am trying to check relative path on Linux for exists.

string mypath = "~/Documents/imgs";


~ is expanded by your shell. It is not a relative path, and 
system calls do not recognize it (same with environmental 
variables).


D can expand tilde with expandTilde:

import std.path : expandTilde;
string mypath = expandTilde("~/Documents/imgs");




Why file.exists of relative path on Linux always return false?

2016-02-29 Thread Suliman via Digitalmars-d-learn

I am trying to check relative path on Linux for exists.

import std.stdio;
import std.path;
import std.file;
import std.string;



string mypath = "~/Documents/imgs";

void main()
{
 if(!mypath.exists)
{
writeln(mypath, " do not exists");
}

 if(!mypath.exists)
{
writeln(mypath, " do not exists");
}

 if("/home/dima/Documents/imgs".exists)
{
writeln("/home/dima/Documents/imgs");
writeln("Dir exists");
}

}

~/Documents/imgs always return "do not exists". But full path: 
"/home/dima/Documents/imgs" is "Dir exists".


Why? It's same paths!



Re: Why file.exists of relative path on Linux always return false?

2016-02-29 Thread Alex Parrill via Digitalmars-d-learn

On Monday, 29 February 2016 at 14:50:51 UTC, Suliman wrote:

I am trying to check relative path on Linux for exists.

import std.stdio;
import std.path;
import std.file;
import std.string;



string mypath = "~/Documents/imgs";

void main()
{
 if(!mypath.exists)
{
writeln(mypath, " do not exists");
}

 if(!mypath.exists)
{
writeln(mypath, " do not exists");
}

 if("/home/dima/Documents/imgs".exists)
{
writeln("/home/dima/Documents/imgs");
writeln("Dir exists");
}

}

~/Documents/imgs always return "do not exists". But full path: 
"/home/dima/Documents/imgs" is "Dir exists".


Why? It's same paths!


~ is expanded by your shell. It is not a relative path, and 
system calls do not recognize it (same with environmental 
variables).


See also 
http://stackoverflow.com/questions/3616595/why-mkdir-fails-to-work-with-tilde


Re: Am I right understand the dub.json system?

2016-02-29 Thread Suliman via Digitalmars-d-learn
On Monday, 29 February 2016 at 13:10:36 UTC, Edwin van Leeuwen 
wrote:

On Monday, 29 February 2016 at 12:45:36 UTC, Suliman wrote:
On Monday, 29 February 2016 at 12:34:02 UTC, Edwin van Leeuwen 
wrote:

Should it be like this?
http://www.everfall.com/paste/id.php?80k9jsgdx6o3

"versions": ["VibeCustomMain"],
"versions": ["USE_MYSQL"],



As far as I know all versions should be on one line:
 "versions": ["VibeCustomMain","USE_MYSQL"],


And by log it's again try to build sqllite.


What does the log actually say? Is it trying to bind to sqlite?



What happens if you also add

"subConfigurations": {
   "ddbc":"MySQL"
}


Thanks, I will check it's later. Now I just drop all other 
strings from ddbc, because now I need to get my app work.


Combining template conditions and contracts?

2016-02-29 Thread Ozan via Digitalmars-d-learn

Is it possible to combine  template conditions and contracts?
Like in the following


T square_root(T)(T x)  if (isBasicType!T) {
in
{
assert(x >= 0);
}
out (result)
{
assert((result * result) <= x && (result+1) * (result+1) > x);
}
body
{
return cast(long)std.math.sqrt(cast(real)x);
}

Compiler says no. Maybe it's a missunderstanding from my side..

Thanks & regards, Ozan


Re: Am I right understand the dub.json system?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn

On Monday, 29 February 2016 at 12:45:36 UTC, Suliman wrote:
On Monday, 29 February 2016 at 12:34:02 UTC, Edwin van Leeuwen 
wrote:

Should it be like this?
http://www.everfall.com/paste/id.php?80k9jsgdx6o3

"versions": ["VibeCustomMain"],
"versions": ["USE_MYSQL"],



As far as I know all versions should be on one line:
 "versions": ["VibeCustomMain","USE_MYSQL"],


And by log it's again try to build sqllite.


What does the log actually say? Is it trying to bind to sqlite?



What happens if you also add

"subConfigurations": {
   "ddbc":"MySQL"
}


Re: Am I right understand the dub.json system?

2016-02-29 Thread Suliman via Digitalmars-d-learn
On Monday, 29 February 2016 at 12:34:02 UTC, Edwin van Leeuwen 
wrote:

On Monday, 29 February 2016 at 12:27:04 UTC, Suliman wrote:
For example I have got app that depended on DDBC. In 
configuration section DDBC related on:


"libs-posix": [
"sqlite3",
"pq"
]

Does it's mean that it will try to find this 2 libs in any 
case? Even I do not use them.


If I do not need them what I should to do? Fix 
~/.dub/packages/ddbc and remove this strings from it, or what?


Reading the dub.json from ddbc it seems you can specify which 
version you want. So if you only need mysql support you add

"versions": ["USE_MYSQL"],
in your own dub.json file.


Should it be like this?
http://www.everfall.com/paste/id.php?80k9jsgdx6o3

"versions": ["VibeCustomMain"],
"versions": ["USE_MYSQL"],

And by log it's again try to build sqllite.



Assoc Array for Concurrency

2016-02-29 Thread Chris via Digitalmars-d-learn
What's the best way to make an assoc array fit for 
multi-threading? If this is not possible what would be the best 
alternative?


Say, for example, `data` is used by a class that is globally 
accessible to all threads. E.g. like this:


string[string] data;  // defined somewhere

public string getData(string key)
{
  if (key in data)
return data[key];
  else
return "";
}


Re: Am I right understand the dub.json system?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn

On Monday, 29 February 2016 at 12:27:04 UTC, Suliman wrote:
For example I have got app that depended on DDBC. In 
configuration section DDBC related on:


"libs-posix": [
"sqlite3",
"pq"
]

Does it's mean that it will try to find this 2 libs in any 
case? Even I do not use them.


If I do not need them what I should to do? Fix 
~/.dub/packages/ddbc and remove this strings from it, or what?


Reading the dub.json from ddbc it seems you can specify which 
version you want. So if you only need mysql support you add

"versions": ["USE_MYSQL"],
in your own dub.json file.


Am I right understand the dub.json system?

2016-02-29 Thread Suliman via Digitalmars-d-learn
For example I have got app that depended on DDBC. In 
configuration section DDBC related on:


"libs-posix": [
"sqlite3",
"pq"
]

Does it's mean that it will try to find this 2 libs in any case? 
Even I do not use them.


If I do not need them what I should to do? Fix 
~/.dub/packages/ddbc and remove this strings from it, or what?


Re: /usr/bin/ld: cannot find -levent_pthreads

2016-02-29 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-02-29 12:58, Guest62942 wrote:

On Monday, 29 February 2016 at 11:48:35 UTC, Suliman wrote:

I have never tried to build my code on Linux (Ubuntu). Now I have error:

/usr/bin/ld: cannot find -levent
/usr/bin/ld: cannot find -levent_pthreads

Where I can get this lib?


http://geeksww.com/tutorials/operating_systems/linux/installation/how_to_install_libevent_on_debianubuntucentos_linux.php


Try `apt search `, you'll need an up to date package manager and
internet access to download.


Make sure it's libevent2 and you install the developer package as well.

--
/Jacob Carlborg


Re: /usr/bin/ld: cannot find -levent_pthreads

2016-02-29 Thread Guest62942 via Digitalmars-d-learn

On Monday, 29 February 2016 at 11:48:35 UTC, Suliman wrote:
I have never tried to build my code on Linux (Ubuntu). Now I 
have error:


/usr/bin/ld: cannot find -levent
/usr/bin/ld: cannot find -levent_pthreads

Where I can get this lib?


http://geeksww.com/tutorials/operating_systems/linux/installation/how_to_install_libevent_on_debianubuntucentos_linux.php

Try `apt search `, you'll need an up to date package 
manager and internet access to download.


/usr/bin/ld: cannot find -levent_pthreads

2016-02-29 Thread Suliman via Digitalmars-d-learn
I have never tried to build my code on Linux (Ubuntu). Now I have 
error:


/usr/bin/ld: cannot find -levent
/usr/bin/ld: cannot find -levent_pthreads

Where I can get this lib?


Re: Why .length on Windows is int and on Linux is ulong?

2016-02-29 Thread ag0aep6g via Digitalmars-d-learn

On 29.02.2016 12:06, Suliman wrote:

On Windows next code work fine:
int len = fullimgurl.length;

On Linux DMD get error that:
Error: cannot implicitly convert expression (fullimgurl.length) of type
ulong to int

Why on every OS length have different size?


On Windows, the compiler flag -m32 is the default, regardless of dmd's 
bitness [1]; on Linux it's -m64 for 64 bit dmd [2]. That's what causes 
the different sizes. Use size_t for lengths, not int or ulong or any 
other specifically sized type.


By the way, with -m32, size_t is uint, not int.


[1] http://dlang.org/dmd-windows.html#switch-m32
[2] http://dlang.org/dmd-linux.html#switch-m64


Re: Why .length on Windows is int and on Linux is ulong?

2016-02-29 Thread Rikki Cattermole via Digitalmars-d-learn

On 01/03/16 12:06 AM, Suliman wrote:

On Windows next code work fine:
int len = fullimgurl.length;

On Linux DMD get error that:
Error: cannot implicitly convert expression (fullimgurl.length) of type
ulong to int

Why on every OS length have different size?


Its not OS dependent, its arch dependent.
On Windows you are building in 32bit mode but on Linux 64bit.



Why .length on Windows is int and on Linux is ulong?

2016-02-29 Thread Suliman via Digitalmars-d-learn

On Windows next code work fine:
int len = fullimgurl.length;

On Linux DMD get error that:
Error: cannot implicitly convert expression (fullimgurl.length) 
of type ulong to int


Why on every OS length have different size?