Re: Variable below zero but if statement doesn't grab?

2015-12-27 Thread Bubbasaur via Digitalmars-d-learn

On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


Tell me one thing, what is the value returned?


Well It's working here: http://dpaste.dzfl.pl/18b27ea26b08

Maybe you would like to change the code above to look like yours 
and see what happens?


Bubba.


Re: Double precision?

2015-12-27 Thread Bubbasaur via Digitalmars-d-learn

On Sunday, 27 December 2015 at 20:06:53 UTC, TheDGuy wrote:

I don't know what my computer is doing today:
x and y are coordinates and if x is any number from 0 to 150 
the result of x/width is always zero


Dividing Integers will result in Integer:

int x = 10, width = 50;

writeln(x/width);   // Will be "0"
writeln(x/cast(double)width); // Will be 0.2

Check out: http://dpaste.dzfl.pl/8bcfb3d9c551


... Another video: https://youtu.be/Fysv2fOwtk4


Please dude, start using dpaste for that, it's a bit nonsense 
watching videos.


Bubba.


Re: GTKD - Get the size of the context

2015-12-26 Thread Bubbasaur via Digitalmars-d-learn

On Saturday, 26 December 2015 at 13:28:31 UTC, TheDGuy wrote:
I get the error "value of 'this' is not known at compile time" 
which refers to the line where i create the int-array "space"

Why is it not possible to use it there?


Just for future newcomers, the answer for the above was given 
here:

http://forum.dlang.org/post/tqvgmsluuhzzscbxh...@forum.dlang.org

By Adam D. Ruppe:

"
Try:

auto arr = new int[](size.width*size.height*3+1);

The int[x] syntax declares a statically sized array - statically 
sized meaning it must be known at compile time and thus cannot be 
variables, along a few other differences.


The new array syntax though returns one of variable size.
"

Bubba.


Re: DMD -L Flag, maybe a bug?

2015-12-26 Thread Bubbasaur via Digitalmars-d-learn

On Saturday, 26 December 2015 at 11:19:27 UTC, anonymous wrote:

...
Note that in the docs I linked it's `dmd hello.d -L+gtkd.lib` 
with a plus sign. I'm not sure if it's significant, but it's a 
difference.


There are two ways in the doc you linked:

dmd hello.d -L+gtkd.lib
or
dmd hello.d -Lgtkd.lib -m64

The second doesn't uses "+" but it has "-m64". Anyway even the 
example with "+" it doesn't working here either.


Also, and this may be it, the link.exe that's distributed with 
dmd doesn't like forward slashes as path separators. You can 
try it with backslashes instead:


dmd test.d -LC:\gtkd\src\build\GtkD.lib


I had tried that before, without any success.

-L doesn't take a space, either. Putting a space there isn't 
even optional, it's wrong. The stuff after the space is not 
passed to the linker, it's interpreted by dmd.


In fact I already had understood what happened after your first 
answer, which "-L" with space wasn't been "evaluated" because DMD 
was reading a flag without arguments. So I could omit it there, 
but like I said, many examples out there uses:
"-Lpath/to/whatever", and then you see many topics about people 
complaining about this.


Bubba.


Re: DMD -L Flag, maybe a bug?

2015-12-26 Thread Bubbasaur via Digitalmars-d-learn
On Saturday, 26 December 2015 at 11:53:55 UTC, Ivan Kazmenko 
wrote:
Note that -L passes flags (options) but not necessarily 
arguments or paths.  For example, I use "dmd 
-L/STACK:268435456" by default along with other options to 
increase the default stack size to 256Mb.


Your comment is reasonable enough, but unfortunately the main 
problem is there are examples on the internet using this "-L" for 
this kind of thing.


If go here: 
http://wiki.dlang.org/Compiling_and_linking_with_DMD_on_Windows#Static_Libraries_and_Import_Paths


There is an example in: "Passing search directories for static 
library files to Optlink", which follows:


C:\Project\main.d
C:\Project\lib\mylib.lib

where main.d depends on the mylib library, you can compile 
via:


dmd -L+.\lib\ driver.d mylib.lib

Yes there is a "+" plus sign and a "." dot there, but I believe 
people gets confuse and uses it as "-I".



Clearly, the forward slash (/) is reserved for switches, so the 
program will have trouble parsing paths with forward slashes.


About this in fact this was my mistake, because originally I had 
tried "\" and since it wasn't working so I change to "/" and that 
remains.


Bubba.


DMD -L Flag, maybe a bug?

2015-12-25 Thread Bubbasaur via Digitalmars-d-learn

If you follow the link below:

https://dlang.org/dmd-windows.html#switch-L

It's written:

"
   -Llinkerflag

   pass linkerflag to the linker link.exe , for example, -L/ma/li
"

But at least on Windows, you need to put a space between -L and 
the PATH. Which It's weird, since with "-I" flag you don't need 
any space.


It took me 30 minutes until I find why my program wasn't 
compiling. (I found the tip on a forum elsewhere).


Is this a bug or a mistake?

Bubba.


Re: DMD -L Flag, maybe a bug?

2015-12-25 Thread Bubbasaur via Digitalmars-d-learn

On Friday, 25 December 2015 at 15:06:27 UTC, anonymous wrote:

...
You can try removing the "-L" entirely. If it still works...


In fact it works without the "-L". Which makes me wonder if I was 
using it wrongly?



What exactly are trying to pass to the linker?


A lib: GtkD.


Can you give a link to that?


Sure (It's the second from the last answer):
http://www.dsource.org/forums/viewtopic.php?t=4928=e1caca2e12a14c49672a92126dc0922c

Bubba.


Re: DMD -L Flag, maybe a bug?

2015-12-25 Thread Bubbasaur via Digitalmars-d-learn

On Friday, 25 December 2015 at 23:45:42 UTC, anonymous wrote:

...
That means a .lib file, right?


Yes.

The GtkD docs say to use -L though [2], so I suppose that 
should work too.


Maybe show your exact complete command line, if you want to 
find out why it doesn't work for you.


It's almost like the example in the URL you showed:

dmd test.d -LC:/gtkd/src/build/GtkD.lib

Where the command above doesn't works, on the other hand the 2 
others below works:


dmd test.d -L C:/gtkd/src/build/GtkD.lib

dmd test.d C:/gtkd/src/build/GtkD.lib


But if you do a search for problems like: Linking problem or 
Symbol Undefined most command lines uses this: 
"-Lpath/to/whatever" (Without Space). And another thing... there 
is other flag commonly used "-I" with doesn't need space, so most 
people will assume the same for -L.


Well this problem took only 30 minutes, because luckily I found 
the answer on the second link, but it could take hours.


Bubba.