Re: Weird behavior of "this" in a subclass, I think?

2015-07-15 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 16 July 2015 at 00:39:29 UTC, H. S. Teoh wrote: If you want to simulate overriding of class variables, you can use a @property method instead: class Animal { @property string voice() { return "Wah!"; } void speak() { writeln(voice); }

Re: Profile Ouput

2015-07-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 July 2015 at 18:02:11 UTC, jmh530 wrote: I've been confused by this too. The only thing I can find is this http://www.digitalmars.com/ctg/trace.html I think it would be cool to write something that takes the output and puts it in a prettier format. Yeah, I eventually stumb

Re: Profile Ouput

2015-07-15 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote: -- 4000 _Dmain _D4main6selectFZk 40002736471 4000 _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk -- OK, I've finally realized that the top part of trace.

Profile Ouput

2015-07-14 Thread Mike Parker via Digitalmars-d-learn
Perhaps my googlefu has failed me, but I can find anything describing the output of DMD's -profile switch. I get that trace.def is a list of all functions called and I understand the table at the bottom of trace.log. What I'm not sure about is everything above the table in trace.log, stuff like

Re: DUB Different Library Name

2015-07-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 July 2015 at 02:14:06 UTC, serh wrote: This is what I get when I run "dub" in the directory: http://codepad.org/BpnOHVSV As mentioned, I already have respective Allegro libs installed, but as liballegro.so.5.0 instead of liballegro-5.0.so and so on. The C++ linker sees them fine

Re: DUB Different Library Name

2015-07-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 July 2015 at 16:43:39 UTC, serh wrote: Hello, I am trying to use Derelict's Allegro 5 in my DUB project, however, when I try to run `dub build` it says it cannot find liballegro-5.0.11.so and liballegro-5.0.so. I have both libraries installed as liballegro.so.5.0.11 and liba

Re: Fixed Length Array Syntax in extern(C) Function Signatures

2015-07-09 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 9 July 2015 at 17:42:33 UTC, Alex Parrill wrote: On Thursday, 9 July 2015 at 17:11:36 UTC, Per Nordlöw wrote: On Thursday, 9 July 2015 at 16:12:27 UTC, Timon Gehr wrote: No. You'll need explicit pass by reference on the D side. So, how should I modify my call to `image_copy` with

Re: Import module

2015-07-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 July 2015 at 00:53:38 UTC, codenstuff wrote: The path is ${HOME}/d_apps/steering/steering/game_object.d Compile command is dmd map/map.d main_visual.d -ofmain_visual -H -gc -unittest -L-lDgame -L-lDerelictUtil -L-lDerelictGL3 -L-lDerelictSDL2 -L-ldl -I/home/real/d_apps/dgame/so

Re: etc.c.zlib help

2015-07-03 Thread Mike Parker via Digitalmars-d-learn
On 7/4/2015 1:28 AM, Matthew Gamble wrote: Wow Mike. This seems like the most likely explanation to me. I'm a bit hesitant to compile phobos from source on this machine with -m32mscoff. Perhaps a similar test would be to compile my program on a 32-bit windows machine? I can do this at work on M

Re: etc.c.zlib help

2015-07-03 Thread Mike Parker via Digitalmars-d-learn
Oh, and issues should be reported at https://issues.dlang.org/.

Re: etc.c.zlib help

2015-07-02 Thread Mike Parker via Digitalmars-d-learn
On 7/3/2015 8:44 AM, Matthew Gamble wrote: Thanks to Nicholas and Laeeth for all the suggestions. In the process of trying to explicitly link to zlib.dll like a do for C++, I came across a strange development. I changed the platform to x64 (Visual D) and now the program compiles and runs fine wit

Re: how to string → uint* ?

2015-06-28 Thread Mike Parker via Digitalmars-d-learn
On 6/28/2015 7:08 PM, "Marc =?UTF-8?B?U2Now7x0eiI=?= " wrote: In addition to what anonymous said, you might want to raise a bug report with Derelict, because the function signatures are arguable wrong, though that depends on whether Derelict wants to provide a strict one-to-one mapping of the C c

Re: Defining constant values in struct

2015-06-16 Thread Mike Parker via Digitalmars-d-learn
On 6/17/2015 6:17 AM, tcak wrote: As far as I known, when I define a string with enum and it is used at different parts of code, that string is repeated again and again in executable file instead of passing a pointer to string. So, using enum with string doesn't seem like a good idea. The string

Re: Conditional Compilation Multiple Versions

2015-06-12 Thread Mike Parker via Digitalmars-d-learn
On 6/13/2015 9:41 AM, bitwise wrote: Is there a way to compile for multiple conditions? Tried all these: version(One | Two){ } version(One || Two){ } version(One && Two){ } version(One) | version(Two){ } version(One) || version(Two){ } version(One) && version(Two){ } Bit // config.d vers

Re: Consevutive calls to r.front

2015-06-07 Thread Mike Parker via Digitalmars-d-learn
On 6/8/2015 12:43 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Monday, June 08, 2015 00:42:07 Mike Parker via Digitalmars-d-learn wrote: When implementing a custom range, is it correct to say that consecutive calls to r.front with no intervening calls to popFront should return the

Re: Consevutive calls to r.front

2015-06-07 Thread Mike Parker via Digitalmars-d-learn
On 6/8/2015 9:55 AM, Dennis Ritchie wrote: On Monday, 8 June 2015 at 00:42:12 UTC, Mike Parker wrote: When implementing a custom range, is it correct to say that consecutive calls to r.front with no intervening calls to popFront should return the same value? Yes. For examle: import std.stdio,

Consevutive calls to r.front

2015-06-07 Thread Mike Parker via Digitalmars-d-learn
When implementing a custom range, is it correct to say that consecutive calls to r.front with no intervening calls to popFront should return the same value? Seems like I read something along those lines before, but I can't find it anywhere.

Re: Array declaration warning

2015-06-02 Thread Mike Parker via Digitalmars-d-learn
On 6/3/2015 1:37 AM, Paul wrote: On Tuesday, 2 June 2015 at 16:23:32 UTC, Adam D. Ruppe wrote: On Tuesday, 2 June 2015 at 16:17:23 UTC, Paul wrote: CoOrd[NumPaths][] pathList; Try CoOrd[][NumPaths]. The order is opposite in D style than in C style (I thnk the D style makes more sense, it jus

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike Parker via Digitalmars-d-learn
On 5/22/2015 10:26 PM, Suliman wrote: Really hard to understand... So what what would call at first ? extern(C) int main() or int _Dmain() Your D programs have multiple layers. There is the C runtime, DRuntime, and your program code. The C runtime is at the bottom. When the program launches

Re: opIndex vs. opSlice for empty slices

2015-05-22 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 May 2015 at 06:28:16 UTC, Ali Çehreli wrote: http://ddili.org/ders/d.en/operator_overloading.html#ix_operator_overloading.opSlice http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.overloading,%20operator Ali Thanks, Ali. I've actually looked over that already an

Re: opIndex vs. opSlice for empty slices

2015-05-21 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 May 2015 at 05:49:17 UTC, weaselcat wrote: http://forum.dlang.org/thread/luadir$t0g$1...@digitalmars.com#post-luadir:24t0g:241:40digitalmars.com Thanks!

opIndex vs. opSlice for empty slices

2015-05-21 Thread Mike Parker via Digitalmars-d-learn
I've always used opSlice to produce empty slices, but having recently read the documentation at [1], I see this: "To overload a[], simply define opIndex with no parameters:" And no mention that opSlice can fill the same role. Am I right to infer that we should prefer opIndex over opSlice for t

Re: Template type deduction and specialization

2015-05-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 May 2015 at 13:46:22 UTC, Daniel Kozák wrote: DOC say `may not have` not `must not have` ;-) OK, if that's the intent, it needs to be reworded. As it stands, it looks more like it's saying specialization is not permissible, rather than what "might" be possible. As in: "Em

Re: Template type deduction and specialization

2015-05-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 May 2015 at 09:35:43 UTC, Daniel Kozak wrote: DOCS: http://dlang.org/template.html#function-templates says: Function template type parameters that are to be implicitly deduced may not have specializations: OK, having reread this, I'm not clear at all what's going on. Here, I

Re: Template type deduction and specialization

2015-05-20 Thread Mike Parker via Digitalmars-d-learn
On 5/20/2015 6:35 PM, Jonathan M Davis via Digitalmars-d-learn wrote: I'm using a fairly recent version of dmd master, and it prints out the address for px in both cases when I compile your code. So, if it's printing out 100 for you on the second call, it would appear to be a bug that has been f

Re: Template type deduction and specialization

2015-05-20 Thread Mike Parker via Digitalmars-d-learn
On 5/20/2015 6:35 PM, Daniel Kozak wrote: DOCS: http://dlang.org/template.html#function-templates says: Function template type parameters that are to be implicitly deduced may not have specializations: Thanks. For the record, the example there is the exact same case. void Foo(T : T*)(T t) { .

Re: Template type deduction and specialization

2015-05-20 Thread Mike Parker via Digitalmars-d-learn
On 5/20/2015 4:36 PM, Namespace wrote: What about: import std.stdio; void printVal(T)(T t) { static if (is(T : U*, U)) printVal(*t); else writeln(t); } Thanks, but I'm not looking for alternatives. I'm trying to figure out why it doesn't work as expected.

Template type deduction and specialization

2015-05-19 Thread Mike Parker via Digitalmars-d-learn
I don't understand why this behaves as it does. Given the following two templates: ``` void printVal(T)(T t) { writeln(t); } void printVal(T : T*)(T* t) { writeln(*t); } ``` I find that I actually have to explicitly instantiate the template with a pointer type to get the specia

Re: DerelictGL3.reload() returns wrong (?) GLVersion (GL32, should be 33)

2015-03-29 Thread Mike Parker via Digitalmars-d-learn
On 3/29/2015 10:26 AM, Koi wrote: Hello, today i implemented OpenGL instancing, and it crashed when calling glVertexAttribDivisor (OpenGL 3.3). So i checked DerelictGL3.reload() and it returned GLVersion.GL32, not GL33. My graphic card (NVidia GT 240) should support GL33 and an OpenGL Extensio

Re: Using std.format required std.string?

2015-03-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 March 2015 at 17:36:24 UTC, Robert M. Münch wrote: Ok, good to here. Didn't cath/remember this one. Is there a way to use "version(...)" to have code sections depending on compiler version? Something like: version(dmd >= 2.067) or version(dmd < 2.067)? static if( __VERSION__

Re: Using std.format required std.string?

2015-03-15 Thread Mike Parker via Digitalmars-d-learn
On Monday, 16 March 2015 at 04:31:19 UTC, Mike Parker wrote: On Sunday, 15 March 2015 at 17:36:24 UTC, Robert M. Münch wrote: Ok, good to here. Didn't cath/remember this one. Is there a way to use "version(...)" to have code sections depending on compiler version? Something like: version(d

Re: SQLite3 and threads

2015-03-02 Thread Mike Parker via Digitalmars-d-learn
On 3/2/2015 4:20 PM, Vitalie Colosov wrote: Now it all makes sense. Thank you. Maybe it would make also some sense if I would have gotten some kind of exception trying to access the variable which was not populated by the running thread, instead of successfully getting empty string... so this wou

Re: DMD Zip for Mac OS X

2015-02-28 Thread Mike Parker via Digitalmars-d-learn
On 2/28/2015 10:36 PM, Jacob Carlborg wrote: On 2015-02-28 07:45, Mike Parker wrote: I'm not a Mac user and I'm fairly clueless about it. The DMD zip for OS X contains one executable. I assume it's a 64-bit binary. Is that true? Yes. Since DMD on OS X got support for 64bit DMD has only been sh

DMD Zip for Mac OS X

2015-02-27 Thread Mike Parker via Digitalmars-d-learn
I'm not a Mac user and I'm fairly clueless about it. The DMD zip for OS X contains one executable. I assume it's a 64-bit binary. Is that true?

Re: Installing DMD From Zip

2015-02-26 Thread Mike Parker via Digitalmars-d-learn
On 2/26/2015 10:06 PM, anonymous wrote: The pages are still there, they're just not linked from anywhere (except for the sitemap). I don't know what happened. On dmd (installation, flags, etc): http://dlang.org/dmd-linux.html http://dlang.org/dmd-windows.html http://dlang.org/dmd-osx.html http

Re: Installing DMD From Zip

2015-02-26 Thread Mike Parker via Digitalmars-d-learn
On 2/26/2015 7:26 PM, Jonathan M Davis via Digitalmars-d-learn wrote: I'd just tell them to unzip it wherever they wanted it and add the bin directory for their platform for it to their PATH. As I recall, that's all that's required to get it to work. Yes, that's about all I can do without that

Installing DMD From Zip

2015-02-26 Thread Mike Parker via Digitalmars-d-learn
Once upon a time, there were instructions linked from the DMD download page explaining how to install from the zip file on each platform. I can't find anything about it now, not from dlang.org or from the wiki. Is it still out there somewhere? I need a page to point people at.

Re: const member function

2015-02-21 Thread Mike Parker via Digitalmars-d-learn
On 2/21/2015 4:31 PM, rumbu wrote: My intention is not to have a read-only getter, I want to call SomeProp on a const object: class S { private int cache = -1; private int SomeExpensiveOp() { return 12345; } public @property const(int) SomeProp() { if (cache = -1)

Re: Is this possible in D?

2015-02-19 Thread Mike Parker via Digitalmars-d-learn
On 2/20/2015 1:06 AM, tcak wrote: @OP: By using a token string (q{}) for funcBody rather than a WYSIWYG string (r"" or ``), you can still get syntax highlighting in your editor. Based on your example, bye bye readibility. It is like writing rocket taking off procedures. People are complaining

Re: Is this possible in D?

2015-02-19 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 19 February 2015 at 10:17:47 UTC, Dicebot wrote: Most practical approach I am currently aware of is wrapping actual implementation (in most restrictive version): I really like mixins for this sort of thing. ``` enum signature = "void longFunction()"; version( Static ) enu

Re: Is this possible in D?

2015-02-19 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 19 February 2015 at 08:24:08 UTC, Jonathan Marler wrote: I am having a heck of a time trying to figure out how to do this. How do I change the attributes of a function based on the version without copying the function body? For example: version(StaticVersion) { static void m

Re: Derelict OpenGL basic program does not work but OpenGL does not say anything is wrong?

2015-02-13 Thread Mike Parker via Digitalmars-d-learn
On 2/13/2015 6:14 PM, Mike Parker wrote: On 2/13/2015 12:46 PM, Bennet wrote: I've begun writing some basic OpenGL code using DerelictGL3 but I've hit a wall. I've managed to open a window (with DerelictSDL2) and call basic OpenGL functions such as glClear(). Still I can not get a basic triangle

Re: Derelict OpenGL basic program does not work but OpenGL does not say anything is wrong?

2015-02-13 Thread Mike Parker via Digitalmars-d-learn
On 2/13/2015 12:46 PM, Bennet wrote: I've begun writing some basic OpenGL code using DerelictGL3 but I've hit a wall. I've managed to open a window (with DerelictSDL2) and call basic OpenGL functions such as glClear(). Still I can not get a basic triangle up and running. glError() does not return

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 6:09 PM, weaselcat wrote: On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. +1 don't complain about people wondering why class destructors don't work when there's no _real_ way to do

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 6:42 AM, ketmar wrote: this problem has very easy solition: we should stop calling class dtors "destructors", and rename them to "finalizers". Absolutely. So many people coming from C++ see "destructor" and want to use them as they did in C++. How often do we see people coming

Re: Comparing function pointers

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 3:40 AM, Freddy wrote: import std.stdio; auto test1(){ void testFunc(){ } return &testFunc; } auto test2(){ uint a; void testFunc(){ a=1; } return &testFunc; } void main(){ writeln(test1()==test1());//true writeln(test2()=

Re: dub.json dependencies per configuration?

2015-02-10 Thread Mike Parker via Digitalmars-d-learn
On 2/11/2015 8:38 AM, Arjan wrote: Snippet from: https://github.com/buggins/ddbc/blob/master/dub.json#L7 ddbc has a "dependencies" on "mysql-native": ">=0.0.12". But this is only true for "configurations": "MySQL". Is it allowed to put the dependency within the configuration section for "MySQL?.

Re: strange work of GC

2015-02-07 Thread Mike Parker via Digitalmars-d-learn
On 2/8/2015 11:32 AM, FG wrote: On 2015-02-08 at 01:20, Mike Parker wrote: In your case, forget destructors and the destroy method. Just implement a common method on all of your objects that need cleanup (perhaps name it 'terminate') and call that. This gives you the deterministic destruction th

Re: strange work of GC

2015-02-07 Thread Mike Parker via Digitalmars-d-learn
On 2/8/2015 4:32 AM, Andrey Derzhavin wrote: Why do you want to use destroy? The destroy method always calls a dtor of the objects, where I can destroy some object's variables in that order that I need, I think. And this is very good for me, because I have a full control of the object's destroyi

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Mike Parker via Digitalmars-d-learn
On 2/6/2015 9:50 AM, Gan wrote: On Friday, 6 February 2015 at 00:35:12 UTC, Adam D. Ruppe wrote: On Friday, 6 February 2015 at 00:31:37 UTC, Gan wrote: Or am I misunderstanding the receive function? Does it send whole messages or just message chunks? It sends as much as it can when you call i

Re: What am I doing Wrong (OpenGL & SDL)

2015-02-05 Thread Mike Parker via Digitalmars-d-learn
On 2/5/2015 4:53 PM, Entity325 wrote: On Thursday, 5 February 2015 at 07:23:15 UTC, drug wrote: Look at this https://github.com/drug007/geoviewer/blob/master/src/sdlapp.d I used here SDL and OpenGL and it worked. Ctor of SDLApp creates SDL window with OpenGL context, may be it helps. Tested yo

Re: What am I doing Wrong (OpenGL & SDL)

2015-02-04 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 February 2015 at 01:51:05 UTC, Entity325 wrote: I am having a problem which is similar in appearance to the OP's, but it does not seem to be similar in function. When I try to execute any of the Gl functions in the (protected) DerelictGL3.gl.loadSymbols function, I get an access

Re: Allegro 5 in C - installing on OSX

2015-02-03 Thread Mike Parker via Digitalmars-d-learn
On 2/3/2015 5:37 PM, Joel wrote: How do you install Allegro 5 (OSX)? Like, using 'Home Brew'. This really isn't the place for that. At allegro.cc there are Allegro-specific forums [1] and an Allegro wiki info on building/installing, where you can find [2]. [1] https://www.allegro.cc/forums/

Re: cast a C char array - offset ?

2015-02-02 Thread Mike Parker via Digitalmars-d-learn
On 2/2/2015 9:16 PM, irtcupc wrote: The manual section about interfacing from c states that "type[]" is inter-compatible from C to D, however, I face this strange case: - C declaration: char identifier[64]; - D declaration: char[64] identifier; - the result is only correct if i slice by (- po

Re: Getting DAllegro 5 to work in Windows

2015-01-30 Thread Mike Parker via Digitalmars-d-learn
On 1/30/2015 6:48 PM, Joel wrote: FYI, I have a nearly finished dynamic binding to Allegro 5 that doesn't require any link-time dependencies. I'll be adding it to DerelictOrg as soon as it's done. I hope that to be sometime on the other side of this coming weekend. I only have a couple more addo

Re: Getting DAllegro 5 to work in Windows

2015-01-29 Thread Mike Parker via Digitalmars-d-learn
On 1/30/2015 3:16 PM, Joel wrote: Update. What happens is, that I run the script file (in DAllegro folder) and it is suppose to create lib files from the DLL ones. On my system, it says its done it but no lib files pop up! It happens on another computer too. (maybe from my dodgy flash drive).

Re: Linking C library (.dll) to D on windows

2015-01-25 Thread Mike Parker via Digitalmars-d-learn
On 1/26/2015 5:45 AM, Roman wrote: Stuff: 1. There are C code module.c and module.h 2. MinGW 3. DMD 2.066.1 4. Window 8.1 module.c: #include "module.h" int add(int a, int b) {return a + b;} module.h: int add(int,int); I want to use function "add" from D so i call cc -shared module.c -o mo

Re: Linking C library (.dll) to D on windows

2015-01-25 Thread Mike Parker via Digitalmars-d-learn
On 1/26/2015 11:18 AM, Mike Parker wrote: * Compile with another compiler and run implib (part of the free Basic Utilities Package from Digital Mars, downloadable from [1]) on the dll to generate an import library in OMF format. [1] http://www.digitalmars.com/download/freecompiler.html

Re: Bug on Posix IPC_STAT. Wrong number of attachments

2015-01-19 Thread Mike Parker via Digitalmars-d-learn
On 1/19/2015 2:35 PM, tcak wrote: On Monday, 19 January 2015 at 04:18:47 UTC, tcak wrote: On Sunday, 18 January 2015 at 22:25:39 UTC, anonymous wrote: On Sunday, 18 January 2015 at 18:07:05 UTC, tcak wrote: After these, it works perfectly. I hope this can be fixed in next version. Please fil

Re: simple assignment statement compiles but becomes a run time error

2015-01-18 Thread Mike Parker via Digitalmars-d-learn
On 1/19/2015 10:44 AM, WhatMeWorry wrote: On Sunday, 18 January 2015 at 20:07:25 UTC, weaselcat wrote: On Sunday, 18 January 2015 at 19:51:02 UTC, WhatMeWorry wrote: On Sunday, 18 January 2015 at 19:42:33 UTC, WhatMeWorry wrote: I've got a OpenGL function returning a pointer // const GLubyte

Re: import conflicts

2015-01-18 Thread Mike Parker via Digitalmars-d-learn
On 1/19/2015 4:37 AM, AndyC wrote: On Sunday, 18 January 2015 at 19:20:34 UTC, Vlad Levenfeld wrote: I get this all the time with std.array.array (I use my own array implementations, but phobos' array seems to secretly creep in everywhere). I think its got to do with that private import visibili

Re: redirecting the unittests error output

2015-01-15 Thread Mike Parker via Digitalmars-d-learn
[1] http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true [2] https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true

Re: redirecting the unittests error output

2015-01-15 Thread Mike Parker via Digitalmars-d-learn
On 1/15/2015 4:32 AM, ref2401 wrote: Unfortunately i'm new to using shells. I use standard windows cmd. Here is my script: dmd main.d -debug -unittest -wi if %errorLevel% equ 0 ( start main.exe ) else ( echo --- Building failed! --- pause ) I wrote "start main.exe 2> errorFile"

Re: Pointers and offsets

2015-01-13 Thread Mike Parker via Digitalmars-d-learn
On 1/14/2015 10:17 AM, Bauss wrote: On Wednesday, 14 January 2015 at 01:16:54 UTC, Bauss wrote: Is it possible to access a pointer by its offsets. Ex. write a 32bit integer to a byte pointer at ex. offset 4. To give an example in C# you can do this: fixed (byte* Packet = Buffer) // Buffer would

Re: How to do equivalent of npm install --save with dub?

2015-01-13 Thread Mike Parker via Digitalmars-d-learn
On 1/13/2015 10:01 AM, Andrew Grace wrote: I am trying to play with D, but I'm getting stuck with the DUB package manager. If use DUB to download a package to my project, how do I get DUB to add what I downloaded to the dub.json file? I have tried DUB --fetch --cache=local http-parser (for examp

Re: How to interface with C++ code or dll?

2015-01-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 January 2015 at 12:56:40 UTC, Suliman wrote: I had read about using C++ libs from D, and understood that there is 2 ways: 1. Make binding - convert .H to .d (I still do not fully understand what is it) 2. Use directly C++ lib (.dll) No, there are not two ways. There is one way.

Re: Need extern (C) interface even though using Derelict GLFW

2015-01-04 Thread Mike Parker via Digitalmars-d-learn
Are they some extremely simple tutorials on bindings and wrappers? Something with lots of code examples. I don't think it's a subject that warrants a tutorial. There's not that much to it. Consider: // capi.h void do_something( const char *str ); // capi.d -- this is a binding exter

Re: Need extern (C) interface even though using Derelict GLFW

2015-01-04 Thread Mike Parker via Digitalmars-d-learn
On 1/4/2015 1:34 PM, WhatMeWorry wrote: Maybe GLFW callback functions can't handled through Derelict GLFW? And just to be clear, because the pointers to the callback functions are being passed to a C API, they *have* to be extern( C ) -- i.e. they have to have the same calling convention tha

Re: Need extern (C) interface even though using Derelict GLFW

2015-01-04 Thread Mike Parker via Digitalmars-d-learn
On 1/4/2015 1:34 PM, WhatMeWorry wrote: Now it resizes the screen successfully, but I feel like I've failed by using extern (C) nothrow. Shouldn't Derelict GLFW be providing a D interface? Maybe GLFW callback functions can't handled through Derelict GLFW? Derelict provides direct bindings, n

Re: Passing string literals to C

2014-12-31 Thread Mike Parker via Digitalmars-d-learn
On 12/31/2014 8:19 PM, Laeeth Isharc wrote: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() { writefln("%s",fromStringz(cpling(

Re: Checking C return results against NULL

2014-12-31 Thread Mike Parker via Digitalmars-d-learn
On 12/31/2014 8:29 PM, Rikki Cattermole wrote: On 1/01/2015 12:22 a.m., Laeeth Isharc wrote: Am I missing a more agreeable way to check the return value of a C function against NULL. It's fine if it's a char*, but if it returns a pointer to some kind of struct, one has to go through and convert

Re: Importing a module from another directory

2014-12-27 Thread Mike Parker via Digitalmars-d-learn
On 12/28/2014 3:01 AM, Derix wrote: But of course ! I should have thought of this myself. Subsequent question though : what is the -I option for ? The dmd embedded help states -Ipath where to look for imports so I'd naively think it would work too, but it yields the same error as above.

Re: Need example of usage DerelictPQ

2014-12-25 Thread Mike Parker via Digitalmars-d-learn
On 12/25/2014 3:03 PM, Suliman wrote: DerelictPQ is only a binding to libpq. The only difference is the DerelictPQ.load method. Just follow the libpq documentation. http://www.postgresql.org/docs/9.1/static/libpq.html Actually, Derelict binds to version 9.3, so the proper link should be http:

Re: Need example of usage DerelictPQ

2014-12-24 Thread Mike Parker via Digitalmars-d-learn
On 12/25/2014 11:23 AM, Mike Parker wrote: On 12/24/2014 8:56 PM, Suliman wrote: Could anybody provide any simple examples of usage DerelictPQ. I do not have experience of C, and I can't understand how to use this driver. I need just basics like connect, select and insert. http://code.dlang.or

Re: Need example of usage DerelictPQ

2014-12-24 Thread Mike Parker via Digitalmars-d-learn
On 12/24/2014 8:56 PM, Suliman wrote: Could anybody provide any simple examples of usage DerelictPQ. I do not have experience of C, and I can't understand how to use this driver. I need just basics like connect, select and insert. http://code.dlang.org/packages/derelict-pq thanks! DerelictPQ

Re: On inheritance and polymorphism in cats and dogs (and other beasts too)

2014-12-21 Thread Mike Parker via Digitalmars-d-learn
On 12/22/2014 1:11 AM, Derix wrote: Yep, I rekon the difference was not clear to me. It still isn't right now, but at least now I know that it exists and I have to look into it. Overriding - a subclass reimplements a method from a base class. The method must have the same number and type of p

Re: How to Declare a new pragma ?

2014-12-21 Thread Mike Parker via Digitalmars-d-learn
On 12/22/2014 9:21 AM, FrankLike wrote: Now ,x64 mainform always have the console window,and the entry is main. could you do it? Thank you. Since 64-bit DMD uses the Microsoft toolchain, you need to pass a parameter on the command line to the MS linker. Linker parameters are pass

Re: On inheritance and polymorphism in cats and dogs (and other beasts too)

2014-12-21 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 21 December 2014 at 15:05:47 UTC, Mike Parker wrote: // Now do Catty things pickiness = (mother.pickiness + father.pickiness) / 2; Sorry, forgot to change that line when I copy-pasted. Should be: pickiness = (catmom.pickiness + catdad.pickiness) / 2;

Re: On inheritance and polymorphism in cats and dogs (and other beasts too)

2014-12-21 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 21 December 2014 at 10:42:37 UTC, Derix wrote: If you change the mother and father parameters from Beasts to Cats, then you aren't overriding anything -- you are /overloading/. That's where the first two errors were coming from. In order for a subclass method to override a base cl

Re: Derelict SDL2 library not loading on OS X

2014-12-20 Thread Mike Parker via Digitalmars-d-learn
On 12/20/2014 11:46 AM, Joel wrote: To uninstall SDL, do I just wipe the framework, and SDL dylib? Sorry, I can't help you there. I have no idea how things are done on Mac. And I think it depends on how it got there in the first place. You may want to take that question to the SDL mailing li

Re: Derelict SDL2 library not loading on OS X

2014-12-19 Thread Mike Parker via Digitalmars-d-learn
On 12/19/2014 7:35 PM, Joel wrote: Now I get this: Joels-MacBook-Pro:dere joelcnz$ ./app derelict.util.exception.SymbolLoadException@source/derelict/util/exception.d(35): Failed to load symbol SDL_GameControllerAddMapping from shared library /usr/local/lib/libSDL2.dylib OK, it looks like you'r

Re: Derelict SDL2 library not loading on OS X

2014-12-18 Thread Mike Parker via Digitalmars-d-learn
On 12/19/2014 9:58 AM, Joel wrote: [snip] derelict.util.exception.SymbolLoadException@derelict/util/exception.d(35): Failed to load symbol SDL_free from shared library /usr/local/lib/libSDL2.dylib OK, the loader is finding libSDL2.dylib in /usr/local/lib where it expects it to be. Your erro

Re: Derelict SDL2 library not loading on OS X

2014-12-18 Thread Mike Parker via Digitalmars-d-learn
On 12/18/2014 3:29 PM, Joel wrote: I've installed SDL2. Joels-MacBook-Pro:DerelictTest joelcnz$ cat test.d import derelict.sdl2.sdl; int main() { DerelictSDL2.load(); } Joels-MacBook-Pro:DerelictTest joelcnz$ dmd test libDerelictSDL2.a libDerelictUtil.a Joels-MacBook-Pro:DerelictTest jo

Re: Wrapping multiple extern (C) declarations in a template

2014-12-13 Thread Mike Parker via Digitalmars-d-learn
On 12/14/2014 4:03 AM, aldanor wrote: However, it wouldn't be possible to retain the same function names since they've been imported to the namespace (it's then also not possible to extern them as private initially since then you won't be able to import/wrap them in a different module). Hence t

Re: Derelict / SDL error

2014-12-10 Thread Mike Parker via Digitalmars-d-learn
On 12/11/2014 4:17 AM, Paul wrote: On Wednesday, 10 December 2014 at 18:58:15 UTC, Paul wrote: The two machines on which errors occur are a Mint 13 (32 bit) box and an ageing laptop with Lubuntu 14.04. I've followed the same procedures but the 64 bit obviously has the 64 bit dmd compiler. Jus

Re: Derelict / SDL error

2014-12-10 Thread Mike Parker via Digitalmars-d-learn
On 12/11/2014 12:31 AM, Paul wrote: This thread has degenerated into a discussion of the set up of my OS which is miles off topic and should probably be abandoned. Maybe not. The trouble is that others have been able to compile and run the same code without error. Given that you are still un

Re: Derelict / SDL error

2014-12-10 Thread Mike Parker via Digitalmars-d-learn
On 12/10/2014 5:59 PM, Paul wrote: Adding that reveals that I need to add SDL_image 2.0 (I didn't know that that wasn't a part of the standard SDL install) so I've compiled that too. I now get the error: Unsupported image format whether I use a png or jpg. int flags = IMG_INIT_PNG | IMG_INIT

Re: Derelict / SDL error

2014-12-09 Thread Mike Parker via Digitalmars-d-learn
On 12/10/2014 12:19 AM, Paul wrote: I don't fancy introduing another layer of complexity in a debugger at present! I wonder if it's the .bmp that's causing the problem. I can't quite figure how to get Derelict SDL_Image into my project at present (dub doesn't fetch it if I add import derelict.s

Re: @property usage

2014-12-09 Thread Mike Parker via Digitalmars-d-learn
On 12/9/2014 4:31 PM, Nicholas Londey wrote: Does @property ever make sense for a free floating function? I would have thought no but was recently asked to add it if using the function with uniform call syntax. I use it from time-to-time. I assume you think of properties as belonging to objec

Re: Derelict / SDL error

2014-12-08 Thread Mike Parker via Digitalmars-d-learn
On 12/8/2014 10:37 PM, Paul wrote: I added this around the problem line to catch the problem: try{ SDL_RenderCopy(renderer, texture, &sourceRect, &destRect); } catch{} finally { writeln( "Error: " , SDL_GetError() ); } The program now works from a termina

Re: Dub / Derelict confusion

2014-11-25 Thread Mike Parker via Digitalmars-d-learn
On 11/26/2014 3:27 AM, Paul wrote: I've finally got this working - the SDL FAQ page sort of identifies the cause; the xorg dev files have to be installed before building SDL otherwise you end up with a 'non-x' version (not sure what you'd do with that!). I built SDL first and then tried installi

Re: DerelictOrg and SDL_Mixer

2014-11-25 Thread Mike Parker via Digitalmars-d-learn
On 11/26/2014 4:42 AM, torea wrote: ok, so basically, each time I want to access some specific functions imported like: import derelict.sdl2.foo; I have to load it like this? DerelictSDL2foo.load(); Don't think of it that way. Think of it this way: you have to load every library you wa

Re: DerelictOrg and SDL_Mixer

2014-11-25 Thread Mike Parker via Digitalmars-d-learn
On 11/25/2014 9:26 AM, torea wrote: Oh.. I didn't know about the DerelictSDL2Mixer.load()! I thought the initialization of sdl_mixer was done with DerelictSDL2.load() Every time you call DerelictFoo.load, you are loading exactly one library. You will never see a Derelict package that loads m

Re: Dub / Derelict confusion

2014-11-22 Thread Mike Parker via Digitalmars-d-learn
On 11/23/2014 3:52 AM, Paul wrote: Whenever I try to learn a new language I always seem to end up fighting the OS or the IDE rather than spending time where I should. Therefore, I'm going to put this idea on hold and stick to console programs for a while (tried to install ncurses as well earlier

Re: Dub / Derelict confusion

2014-11-20 Thread Mike Parker via Digitalmars-d-learn
On 11/21/2014 10:22 AM, Mike Parker wrote: You are adding anything You /aren't/

Re: Dub / Derelict confusion

2014-11-20 Thread Mike Parker via Digitalmars-d-learn
On 11/21/2014 5:57 AM, Paul wrote: This is a tad off topic now but I'm struggling to get a window on screen as SDL_CreateWindow is failing, here's what I've got: try{ DerelictSDL2.load(); }catch(Exception e){ writeln("Failed to load DerelictSDL2 :( %s", e.msg); return; } Befor

Re: help

2014-11-20 Thread Mike Parker via Digitalmars-d-learn
On 11/20/2014 3:38 PM, michael via Digitalmars-d-learn wrote: Hello All: when i am using std.net.curl to download a file that dosent exist on ftp sever,my code will get an execption like this " ‍std.net.curl.CurlException@std\net\curl.d(3605

Re: Dub / Derelict confusion

2014-11-19 Thread Mike Parker via Digitalmars-d-learn
On 11/19/2014 6:12 PM, Paul wrote: I would like to create a simple program using SDL. I've read this page http://dblog.aldacron.net/derelict-help/using-derelict/ and this one http://code.dlang.org/about and decided that using 'dub' would be the sensible option for a beginner so I downloaded the d

Re: Howto use an alternative Linker with DUB?

2014-11-16 Thread Mike Parker via Digitalmars-d-learn
On 11/16/2014 6:46 AM, univacc wrote: Hi, I am sitting in front of this problems for hours now and I need help: I need the a linker that is capable of delayed DLL loading and apparently, OPTLINK does not provide this option. unilink and Microsofts incremental linker support it so I would like t

Re: Callbacks in D as void functions

2014-11-13 Thread Mike Parker via Digitalmars-d-learn
On 11/14/2014 12:58 AM, Wsdes wrote: Anyway, I think I got the problem solved. Well, there seems to never have been any problem as I am taught now. I asked the developer of the C API this morning if I should try to implement the callback functions redundantly in D and he said he will have a look

<    7   8   9   10   11   12   13   >