Re: MySQL

2012-01-22 Thread Ali Çehreli

On 01/21/2012 06:28 PM, Mars wrote:

On Sunday, 22 January 2012 at 00:50:28 UTC, Ali Çehreli wrote:

Are you also including the library on the command line with -L-l? For
example, for ncurses:

dmd ... -L-lncurses ...

And if needed, also -L-L to specify the location of library files for
the linker.

Ali


Yes, I am including it. Tried pragma and command line. And I don't get a
message that the lib couldn't be found.
What exactly is -L-l supposed to do? Is this valid in DMD 2.057? I get
an error with it (Unknown Option).

Mars


-L is dmd's the linker flag option. Anything after that is passed to the 
linker. So -L-l passes -l to the linker:


  http://www.d-programming-language.org/dmd-linux.html

Ali


Re: MySQL

2012-01-22 Thread DNewbie


On Sun, Jan 22, 2012, at 12:11 AM, Ali Çehreli wrote:
 On 01/21/2012 06:28 PM, Mars wrote:
  On Sunday, 22 January 2012 at 00:50:28 UTC, Ali Çehreli wrote:
  Are you also including the library on the command line with -L-l? For
  example, for ncurses:
 
  dmd ... -L-lncurses ...
 
  And if needed, also -L-L to specify the location of library files for
  the linker.
 
  Ali
 
  Yes, I am including it. Tried pragma and command line. And I don't get a
  message that the lib couldn't be found.
  What exactly is -L-l supposed to do? Is this valid in DMD 2.057? I get
  an error with it (Unknown Option).
 
  Mars
 
 -L is dmd's the linker flag option. Anything after that is passed to the 
 linker. So -L-l passes -l to the linker:
 
http://www.d-programming-language.org/dmd-linux.html
 
 Ali
 


I've took a look at MySQL headers, the functions use __stdcall, but in 
libmysql.dll exports table they are not decorated.



Re: MySQL

2012-01-22 Thread Mars

On Sunday, 22 January 2012 at 08:11:21 UTC, Ali Çehreli wrote:
-L is dmd's the linker flag option. Anything after that is 
passed to the linker. So -L-l passes -l to the linker:


 http://www.d-programming-language.org/dmd-linux.html

Ali


Let me rephrase that, is this valid for OPTLINK?

Unknown Option : LLIBMYSQL
Normally I just include the lib files in the files list (dmd 
foo.d bar.lib).


Mars


Re: MySQL

2012-01-22 Thread Mars

On Sunday, 22 January 2012 at 10:21:29 UTC, DNewbie wrote:
I've took a look at MySQL headers, the functions use   stdcall, 
but in libmysql.dll exports table they are not decorated.


This means...?
Shouldn't it at least compile, if they are listed in the def 
file, coming from the lib?


for loop

2012-01-22 Thread RenatoL
This works:

import�std.stdio;
void�main()
{
int�x =�0;
int�y =�0;
for(;�((x��5)��(y��5));�x++,�y�++)
{
writeln(x + y = ,�x�+�y);
}
}

The question is easy: is it possible to insert x and y internally
in the for header? that is something like C#

for (int x = 0, int y = 0; .)

this doesn't work in D.


Re: for loop

2012-01-22 Thread Trass3r

for (int x = 0, int y = 0; .)


for (int x=0, y=0; ...)


Re: for loop

2012-01-22 Thread RenatoL
Ops, tk u .. sometimes C# is a bad teacher :-)


Re: for loop

2012-01-22 Thread Max Klyga

On 2012-01-22 16:23:36 +0300, RenatoL said:


This works:

import std.stdio;
void main()
{
int x = 0;
int y = 0;
for(; ((x  5)  (y  5)); x++, y ++)
{
writeln(x + y = , x + y);
}
}

The question is easy: is it possible to insert x and y internally
in the for header? that is something like C#

for (int x = 0, int y = 0; .)

this doesn't work in D.


If you want to declare and initialize several variables in the for 
loop, you can do it if they are of the same type:


for (int x = 0, y = 0; ...; .++x, ++y) { ... }



Re: for loop

2012-01-22 Thread bearophile
Max Klyga:

 If you want to declare and initialize several variables in the for 
 loop, you can do it if they are of the same type:
 
 for (int x = 0, y = 0; ...; .++x, ++y) { ... }

And if you need different types this sometimes is enough:

void main() {
for (auto x = 0, y = 0.0; x  10; x++, y++) {
}
}

Bye,
bearophile


Re: for loop

2012-01-22 Thread Zachary Lund

On 01/22/2012 11:08 AM, bearophile wrote:

Max Klyga:


If you want to declare and initialize several variables in the for
loop, you can do it if they are of the same type:

for (int x = 0, y = 0; ...; .++x, ++y) { ... }


And if you need different types this sometimes is enough:

void main() {
 for (auto x = 0, y = 0.0; x  10; x++, y++) {
 }
}

Bye,
bearophile


This is an ugly solution (and I'm not 100% sure it's valid D) but:

/+/
void main() {
{
short y = 0;
int x = 0;

for (; x  10; ++x, ++y)
{
}
}
}
/+/


Re: for loop

2012-01-22 Thread Zachary Lund

On 01/22/2012 11:37 AM, Zachary Lund wrote:

On 01/22/2012 11:08 AM, bearophile wrote:

Max Klyga:


If you want to declare and initialize several variables in the for
loop, you can do it if they are of the same type:

for (int x = 0, y = 0; ...; .++x, ++y) { ... }


And if you need different types this sometimes is enough:

void main() {
for (auto x = 0, y = 0.0; x 10; x++, y++) {
}
}

Bye,
bearophile


This is an ugly solution (and I'm not 100% sure it's valid D) but:

/+/
void main() {
{
short y = 0;
int x = 0;

for (; x  10; ++x, ++y)
{
}
}
}
/+/


LOL, well... I missed the post that said the exact same thing I did. Oh 
well...


Re: MySQL

2012-01-22 Thread Jesse Phillips

On Sunday, 22 January 2012 at 12:11:58 UTC, Mars wrote:

Let me rephrase that, is this valid for OPTLINK?

Unknown Option : LLIBMYSQL
Normally I just include the lib files in the files list (dmd 
foo.d bar.lib).


Mars


No, in fact I couldn't find how to pass a library search path to 
optlink. It can be added to the sc.ini file, but I couldn't find 
a command line option. -l is an ld flag.


Re: Reading web pages

2012-01-22 Thread Bystroushaak

Fixed. Bug was caused by HTTP 1.0 'HTTP 1.0 200 OK' reply.

On 21.1.2012 13:14, Xan xan wrote:

With png works, with pdf not:

  ./spider2 http://www.google.com/intl/ca/images/logos/mail_logo.png
[a lot of output]

$ ./spider2 http://static.arxiv.org/pdf/1109.4897.pdf
[Longitud: [Excepció:
std.conv.ConvException@/usr/include/d2/4.6/std/conv.d(1640): Can't
convert value `HTT' of type string to type uint]


2012/1/20 Bystroushaakbystrou...@kitakitsune.org:

On 20.1.2012 18:42, Xan xan wrote:


Thank you very much. I should invite you to a beer ;-)



Write me if you will be in prag/czech republic :)



For the other hand,

I get this error:

[Excepció: std.conv.ConvException@/usr/include/d2/4.6/std/conv.d(1640):
Can't convert value `HTT' of type string to type uint]



This is very strange error, because on my computer it works well. Can you
remove try..catch and post full error list and program parameters?


Re: MySQL

2012-01-22 Thread DNewbie
On Sun, Jan 22, 2012, at 01:13 PM, Mars wrote:
 On Sunday, 22 January 2012 at 10:21:29 UTC, DNewbie wrote:
  I've took a look at MySQL headers, the functions use   stdcall, 
  but in libmysql.dll exports table they are not decorated.
 
 This means...?
 Shouldn't it at least compile, if they are listed in the def 
 file, coming from the lib?
 

You should add 'extern(Windows)', but it would not work anyway.
Can someone confirm the oplink does not handle this type of module (undecorated 
stdcall functions)?




eof of socketstream?

2012-01-22 Thread useo6
Hey guys,

is there any way to find the end a socketstream? When I use:

MemoryStream ms = new MemoryStream();
while (s.socket().isAlive()) ms.write(s.getc());

I run into an endless loop. The socket doesn't send the size of the data, so I
need to know when I received all the data. How can I figure out that I received
all data?

thx for any help!


Re: MySQL

2012-01-22 Thread Kapps

The way I did it is
1) Download C connector from mysql's website, 6.0.2 is version headers 
were made for. Remember you'll need the 32-bit one if you're using DMD 
on Windows.

2) Create the binding functions using extern(System).
3) For Windows, use 'coffimplib libmysql.dll libmysql.lib', and build 
with PathToFile/libmysql.lib. Example: 'dmd test.d libmysql.lib'
3b) For Linux, just link to libmysqlclient. a with -Llibmysqlclient.a 
or by just passing path.
4) Make sure that libmysql.dll (for Windows) is in the application 
folder otherwise you'll get errors when trying to run.


On 21/01/2012 3:38 PM, Mars wrote:

Hello everyone.
I've been trying to use MySQL in an application on Windows, but I always
get

Symbol Undefined _mysql_init

I've put the lib in the correct folder, so I don't know what the problem
might be. I've tried several libs, and tried to compile it myself
(always converted using coffimplib), but it fails, no matter what. I've
also tried to make a def file out of the lib, and the functions are
definitly listed as exports there.
Any idea what I might doing wrong?

Mars




no-argument constructor: is this a bug?

2012-01-22 Thread Caligo
struct A(uint samples){

  float[samples] _data = void;

  this(float val = 0.0f){ fill(_data[], val); }
}


  auto a = A!8();

a._data is filled with garbage instead of zeros because the
no-argument constructor is called instead of the one that I've
defined.


Re: no-argument constructor: is this a bug?

2012-01-22 Thread Timon Gehr

On 01/23/2012 12:51 AM, Caligo wrote:

struct A(uint samples){

   float[samples] _data = void;

   this(float val = 0.0f){ fill(_data[], val); }
}


   auto a = A!8();

a._data is filled with garbage instead of zeros because the
no-argument constructor is called instead of the one that I've
defined.


structs are always default-constructible, and, as a tie-breaker, a 
function definition that has the exact number of arguments is considered 
a better match one that has to supply default-arguments to match. You 
could use a static opCall to make auto a = A!8() work.


Re: no-argument constructor: is this a bug?

2012-01-22 Thread Jonathan M Davis
On Sunday, January 22, 2012 17:51:36 Caligo wrote:
 struct A(uint samples){
 
   float[samples] _data = void;
 
   this(float val = 0.0f){ fill(_data[], val); }
 }
 
 
   auto a = A!8();
 
 a._data is filled with garbage instead of zeros because the
 no-argument constructor is called instead of the one that I've
 defined.

http://d.puremagic.com/issues/show_bug.cgi?id=3438

It should be illegal to have a struct constructor where all of its parameters 
have default arguments. If you want to have all default arguments, then use 
static opCall instead.

- Jonathan M Davis


Re: MySQL

2012-01-22 Thread DNewbie


On Sun, Jan 22, 2012, at 11:02 PM, DNewbie wrote:
 On Sun, Jan 22, 2012, at 01:13 PM, Mars wrote:
  On Sunday, 22 January 2012 at 10:21:29 UTC, DNewbie wrote:
   I've took a look at MySQL headers, the functions use   stdcall, 
   but in libmysql.dll exports table they are not decorated.
  
  This means...?
  Shouldn't it at least compile, if they are listed in the def 
  file, coming from the lib?
  
 
 You should add 'extern(Windows)', but it would not work anyway.
 Can someone confirm the oplink does not handle this type of module
 (undecorated stdcall functions)?
 
 
 

You can try

// - libmysql.def ---
LIBRARY libmysql.dll
EXETYPE NT
SUBSYSTEM WINDOWS
EXPORTS
_mysql_init@4=mysql_init
// 

// --- mysqltest.d 
import libmysql;
alias void MYSQL;

int main()
{
  MYSQL *m = libmysql.mysql_init(null);
  return 0;
}
// ---

// --- libmysql.di ---
alias void MYSQL;
export extern (Windows) MYSQL *mysql_init(MYSQL *);
// 

$ implib /system libmysql.lib libmysql.def
$ dmd mysqltest.d libmysql.lib

It works..



Re: MySQL

2012-01-22 Thread Mars

On Sunday, 22 January 2012 at 23:23:23 UTC, Kapps wrote:

2) Create the binding functions using extern(System).


Oh man... that was the problem. The file I used was using 
extern(C). Thought that was okay, it's a C lib after all. Thank 
you!


Mars