Re: Enum that can be 0 or null

2016-05-20 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 21 May 2016 at 01:09:42 UTC, Alex Parrill wrote: Looks like my best bet is to mark it as deprecated and point them to Vk(Type).init instead. I would prefer to do something like this: enum VK_NULL_HANDLE_0 = 0; enum VK_NULL_HANDLE_PTR = null; Then document it clearly. Alias

Re: Enum that can be 0 or null

2016-05-20 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2016 at 22:10:51 UTC, tsbockman wrote: Just use null for pointer types, and 0 for integers. D is not C; you aren't *supposed* to be able to just copy-paste any random C snippet into D and expect it to work without modification. If that's not a satisfactory answer, please

Re: Compile Tango for DMD2 - Any instructions how to do it?

2016-05-17 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 17 May 2016 at 21:49:28 UTC, TheDGuy wrote: Okay i now have several ".obj" files in "Tango-D2-d2port\build\bin\win32" but how can i merge them to a library? Anyone here who knows that? Seigelord's port to D2 has a dub.json file, so you should be able to do this: cd

Re: Compile Tango for DMD2 - Any instructions how to do it?

2016-05-17 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 17 May 2016 at 17:40:40 UTC, TheDGuy wrote: Manually Build and Install This is recommended for end users who are installing into an existing compiler, and for developers who wish to work on Tango itself. This section is out of date. ???" All of dsource.org is outdated. It's

Re: Does DUB create .dll files?

2016-05-17 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 17 May 2016 at 05:30:33 UTC, WhatMeWorry wrote: I just incorporated DerelictALURE into a project and it compiled and linked fine, but when I ran the executable, it aborted with:

Re: How do you use D to launch/open a window?

2016-04-23 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 April 2016 at 21:29:29 UTC, anonymousuer wrote: On Friday, 22 April 2016 at 21:26:25 UTC, ciechowoj wrote: On Friday, 22 April 2016 at 21:13:31 UTC, anonymousuer wrote: What code is needed to tell D to open a window? Thank you in advance. Could you specify what kind of window

Re: DUB and static libs

2016-04-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 10:19:10 UTC, abad wrote: I have a project which is a mixture of D, C++ and C. I have used Make for build automation so far but would like to migrate to DUB. I have hard time figuring out what to do with C / C++ sections of the program. DUB seems to ignore

Re: DUB and static libs

2016-04-20 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 13:12:54 UTC, Mike Parker wrote: "libs": [ "stdc++", "sid.a" ], Oh, if you're using DMD only you can also pass configure it using sourceFiles: "sourceFile": ["/path/to/libsid.a"] The first is the equivalant of: dmd -L-lsid main.d ... And the second: dmd

Re: Dub and derelict-allegro5 "Could not find a valid dependency tree configuration"

2016-04-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 April 2016 at 11:21:25 UTC, Pedro Lopes wrote: In the second paragraph I meant to say: The first library that Derelict-Allegro (not dub) looks for is called: "liballegro_image-5.0.11.so" ... I know dub has nothing to do with this at this point it already compile and linked it

Re: Dub and derelict-allegro5 "Could not find a valid dependency tree configuration"

2016-04-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 April 2016 at 09:19:14 UTC, Pedro Lopes wrote: I changed the dub.sdl dependency to version 0.0.5, but dub cant recognize that version: "Root package allegrotest contains reference to invalid package derelict-allegro5 0.0.5" My fault. I forgot to 'git push --tags'. Once the

Re: Dub and derelict-allegro5 "Could not find a valid dependency tree configuration"

2016-04-11 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 April 2016 at 10:34:58 UTC, Pedro Lopes wrote: it is definitely derelict-allegro5's fault. Yes. As I said in my second post, change your dependency to 0.0.5 and you should be good to go.

Re: Internal compiler erorr

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 April 2016 at 17:19:14 UTC, Eric wrote: I am getting this error when I compile: Error: Internal Compiler Error: unsupported type const(string) No line number is given. Does anyone know what causes this? compiler version = v2.071.0 -Eric An ICE should always be considered a

Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 April 2016 at 22:03:54 UTC, Zekereth wrote: So I was just testing some code and couldn't figure out why it wasn't working. My version block looked like this: version(Linux) { ... } Looking at the list(unless I'm missing something) Linux is the only OS that is lowercase. I'm

Re: version pairs?

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 April 2016 at 13:58:17 UTC, Jay Norwood wrote: Seems like there should be an extra level to the version statement, something like version(arch,x86). I must be missing something about the intended use of the version statement. What's wrong with version(X86)?

Re: Dub and derelict-allegro5 "Could not find a valid dependency tree configuration"

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 April 2016 at 12:14:54 UTC, Pedro Lopes wrote: Hello, Every time I try to run a project with derelict-allegro5 package as a dependency, dub says: "Could not find a valid dependency tree configuration" I already cleaned the dub cache, that does not solve it, allegro package is

Re: Dub and derelict-allegro5 "Could not find a valid dependency tree configuration"

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 April 2016 at 00:36:28 UTC, Mike Parker wrote: You say it happens when you try to "run" a project, but the error message sounds like it's happening before building even begins, correct? What platform are you on? What does your dub configuration look like? What does 'dub build

Re: is std.algorithm.joiner lazy?

2016-04-08 Thread Mike Parker via Digitalmars-d-learn
On Friday, 8 April 2016 at 03:20:53 UTC, Puming wrote: On Friday, 8 April 2016 at 02:49:01 UTC, Jonathan M Davis wrote: [...] Thanks. I'll adopt this idiom. Hopefully it gets used often enough to warrent a phobos function :-) What would such a function look like? I don't think such a thing

Re: Problem using shared D library from C shared library

2016-04-06 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 7 April 2016 at 01:50:31 UTC, Yuxuan Shui wrote: On Thursday, 7 April 2016 at 01:42:54 UTC, rikki cattermole wrote: On 07/04/2016 1:38 PM, Yuxuan Shui wrote: [...] Have you started D's runtime? How to start D's runtime? I followed the examples found here:

Re: Putting things in an enum's scope

2016-04-06 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 13:59:42 UTC, pineapple wrote: Is there any way in D to define static methods or members within an enum's scope, as one might do in Java? It can sometimes help with code organization. For example, this is something that coming from Java I'd have expected to be

Re: Decompressing bzip2

2016-04-05 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 19:27:20 UTC, Charles Hixson wrote: ... Are you asserting that scope is soon to be officially deprecated? I'm finding "shouldn't really be used at all anymore" a bit of a worrying statement, as I much prefer the syntax used by scope. Why shouldn't it "be used at

Re: Convert wchar* to wstring?

2016-04-05 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 07:10:50 UTC, tsbockman wrote: You can also combine both steps into a one-liner: wstring wstr = cw[0 .. cw_len].idup; This should do the trick, too: import std.conv : to; auto wstr = to!wstring(cw);

Re: Decompressing bzip2

2016-04-04 Thread Mike Parker via Digitalmars-d-learn
On Monday, 4 April 2016 at 21:32:10 UTC, stunaep wrote: Can you please explain what the scope keyword does and if there scope was originally intended to be used primarily with classes in order to get deterministic destruction. It ensures the destructor of a class is called when the scope

Re: how to declare C's static function?

2016-03-28 Thread Mike Parker via Digitalmars-d-learn
On Monday, 28 March 2016 at 14:40:40 UTC, Adam D. Ruppe wrote: On Monday, 28 March 2016 at 04:53:19 UTC, aki wrote: So... You mean there are no way to declare functions without exporting the symbol? alas, no, even if it is private it can conflict on the outside (so stupid btw). Seems to

Re: SDL Error: identifier expected following '.', not 'version'

2016-03-27 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 27 March 2016 at 08:52:11 UTC, Mike Parker wrote: When using Derelict, BTW, I should caution that the Sys_WM stuff in Derelict may be buggy. If you run into any odd behavior, feel free to blame it on Derelict (as long as you report it!).

Re: SDL Error: identifier expected following '.', not 'version'

2016-03-27 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 27 March 2016 at 07:55:10 UTC, Pedro Lopes wrote: BTW, i'm following the SDL official documentation (written for C): https://wiki.libsdl.org/SDL_GetWindowWMInfo Derelict SDL is fine, I have compiled SDL code before. I Know that the word "version" is reserved for D, but how do I

Re: Compiler Specific dub Dependencies

2016-03-23 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 20:30:04 UTC, Jack Stouffer wrote: Is there any way in dub to specify that a module should only be linked and compiled for DMD and not for LDC? I am using the Economic Modeling containers library, and because it uses std.experimental.allocator, it can't be used

Re: Class member always has the same address

2016-03-20 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 20 March 2016 at 09:53:07 UTC, szymski wrote: Ok, I understand now, thanks. I used C# a lot before and there default initialization worked like per instance initialization. Yes, I assumed you were thinking of C# or Java classes with this. When coming to a new language, it's

Re: Class member always has the same address

2016-03-19 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 19 March 2016 at 20:24:15 UTC, szymski wrote: class A { B b = new B(); } This is *default* initialization, not per instance initialization. The compiler will create one instance of B and it will become the default initializer of b in *every* instance of A. You can

Re: Using tango or other static lib in static lib

2016-03-15 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 15 March 2016 at 08:40:31 UTC, Jaocb Carlborg wrote: On Tuesday, 15 March 2016 at 06:54:45 UTC, Zardoz wrote: Not would be more easy to simply add a dependency to tango on dub.SDL ? I ask... Yes. Mike gave a very long explanation that can be summed up by saying: add Tango as a

Re: std.stdio.File.seek error

2016-03-14 Thread Mike Parker via Digitalmars-d-learn
On Monday, 14 March 2016 at 14:19:27 UTC, stunaep wrote: I'm on my phone but I think It said something like Deprecation: module std.stdio not accessible from here. Try import static std.stdio Deprecation: module std.stdio is not accessible here, perhaps add 'static import std.stdio;' The

Re: Specialized template in different module

2016-03-14 Thread Mike Parker via Digitalmars-d-learn
On Monday, 14 March 2016 at 08:42:58 UTC, John wrote: If I define a template in one module, and specialize it in a second module, the compiler doesn't like it when I try to call a function using the template. If I put everything in the same module it works. So are template specializations

Re: std.stdio.File.seek error

2016-03-14 Thread Mike Parker via Digitalmars-d-learn
On Monday, 14 March 2016 at 09:57:19 UTC, stunaep wrote: It looks like _fseeki64 is in the nightly build but not dmd 2.070.2; However, the nightly build says std.stdio and std.conv are deprecated and I cant use them. I think you may be misinterpreting the error message. There was a change

Re: Using tango or other static lib in static lib

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 13 March 2016 at 01:06:33 UTC, Mike Parker wrote: it. Assuming both files live in the same directory, they can be compiled with this command: Somehow I deleted that line: dmd main.d something.d

Re: Using tango or other static lib in static lib

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 22:34:19 UTC, Voitech wrote: At beginning I want to say that I'm Java devloper so most of linking, joining, dependent classes, libs could be solve with simple 3 click in eclipse so please be patient with me :). I'm using Mono-D under Ubuntu 14.04 to create my

Re: Filling an array

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 14:33:19 UTC, Alex wrote: //arr[] = 1; The question is, why the commented out line throws the error: Error: cannot implicitly convert expression (1) of type int to Nullable!uint[], while the line after that works. Looks like a bug somewhere. The work

Re: Why is it not possible to write to a file from a const member function ?

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 14:02:31 UTC, user42 wrote: Why is this thing not compiling ? Or, in other words, how is is possible to log something to a file from a const member function ? Const member functions functions are not allowed to mutate any member state at all. This includes

Re: BZ2 library

2016-03-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 06:50:59 UTC, stunaep wrote: On Saturday, 12 March 2016 at 06:07:25 UTC, Mike Parker wrote: [...] I used visual studio 2013 to build the libraries With dflag -m64 and dub flag --arch=x86_64, this happens You shouldn't specify -m64 in your configuration. DUB

Re: BZ2 library

2016-03-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 March 2016 at 05:16:37 UTC, stunaep wrote: I'm really having a hard time using bzp (and later I need gzip and lzma). So I added this bzip2 D interface to my DUB dependencies "dependencies" : { "bzip2": "~>0.1.0" } I downloaded the bzip2 source code and compiled

Re: Use of GUID constants

2016-03-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 10 March 2016 at 14:52:16 UTC, KlausO wrote: For GUIDs you often have to take the address (e.g. for calls to QueryInterface), so I think phobos does not correctly implement this. Yes, that was my meaning. Is the above pair (const GUID and static member) the right way to

Re: Use of GUID constants

2016-03-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 10 March 2016 at 10:16:30 UTC, KlausO wrote: Ok, but what's the intention behind defining GUIDs as enums in the first place ? Probably just an implementation error, i.e. someone not fully appreciating how GUIDs are intended to be used. Is there a recommended way to

Re: How to import for mixin contents only.

2016-03-09 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 10 March 2016 at 04:07:54 UTC, Taylor Hillegeist wrote: So i want bitfields for just a little bit. but i dont want its dependencies. How is it done. I have tried this. but it doesnt seem to work on gdc. :( struct Color_t { static if(__ctfe){ import

Re: Application with WinMain does not start

2016-03-05 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 5 March 2016 at 14:01:11 UTC, Mike Parker wrote: If you use WinMain, you do not need that flag. Actually, I need to amend that. It isn't needed with WinMain when using the Microsoft linker, but it is when using OPTLINK. The MS linker recognizes WinMain and treats it as

Re: Application with WinMain does not start

2016-03-05 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 5 March 2016 at 13:16:19 UTC, Minas Mina wrote: I added a WinMain function to my application because I don't want it to open a console when running on windows. But now it doesn't even start... extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

Re: efficient and safe way to iterate on associative array?

2016-03-04 Thread Mike Parker via Digitalmars-d-learn
On Friday, 4 March 2016 at 13:53:22 UTC, aki wrote: Is it okay to modify associative array while iterating it? import std.stdio; void main() { string[string] hash = [ "k1":"v1", "k2":"v2" ]; auto r = hash.byKeyValue(); while(!r.empty) { auto key =

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 10:57:35 UTC, Luis wrote: Read https://dlang.org/spec/arrays.html#strings and try to use std.string.toStringz (http://dlang.org/phobos/std_string.html#.toStringz) Yes, but that's not what you use when you want to avoid allocation.

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 04:12:13 UTC, Mike Parker wrote: char buf[1024]; Ugh. And the proper declaration in D: char[1024] buf;

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 01:39:13 UTC, David G. Maziero wrote: Consider the following function: void RenderText( FontBMP font, int x, int y, const char* text ) { for( int r=0; text[r]!='\0'; ++r ) { You're asking for trouble here. There's no guarantee that any D

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

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

Re: ErrnoException

2016-02-28 Thread Mike Parker via Digitalmars-d-learn
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.

Re: dub: how to reference a compiled package

2016-02-25 Thread Mike Parker via Digitalmars-d-learn
On Friday, 26 February 2016 at 04:03:15 UTC, BBasile wrote: The D interface file must be specified to DUB using "sourceFiles" : ["folder/interface.di"], either in a config or in the globals. The binary, so either a .lib | .a or .obj | .o must be specified to DUB using "DFlags" :

Re: dub: how to reference a compiled package

2016-02-25 Thread Mike Parker via Digitalmars-d-learn
On Friday, 26 February 2016 at 03:19:26 UTC, mahdi wrote: Great! Thanks. I was looking for a feature like `jar` files in Java or `assemblies` in C# where all compiled code and metadata/symbols are stored together inside a single binary file. I think same can be implemented for D language

Re: dub: how to reference a compiled package

2016-02-25 Thread Mike Parker via Digitalmars-d-learn
On Friday, 26 February 2016 at 02:49:20 UTC, Mike Parker wrote: The compiler needs to know about S and its types, and it needs S and its *members*

Re: dub: how to reference a compiled package

2016-02-25 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 25 February 2016 at 21:06:59 UTC, mahdi wrote: On Thursday, 25 February 2016 at 16:45:46 UTC, Chris Wright Thanks. Is there a way to use a D library without having access to it's source code? I tried `dmd -lib abcd.d` which creates a static library. But still I need to specify

Re: vk.xml

2016-02-23 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 24 February 2016 at 00:50:40 UTC, Nicholas Wilson wrote: AA's are nice in theory but the non-deterministic nature of their order of iteration is painful... An ordered map as the default AA implementation would be worse. Most use cases for a hash map don't need ordering.

Re: Simple performance question from a newcomer

2016-02-23 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 23 February 2016 at 20:03:30 UTC, dextorious wrote: For instance, I am still not sure how to make it pass the -O5 switch to the LDC2 compiler and the impression I got from the documentation is that explicit manual switches can only be supplied for the DMD compiler. If you're

Re: SIGSEGV when using D DLL with Qt MinGW

2016-02-23 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 23 February 2016 at 08:50:45 UTC, Jerry wrote: I am using the following environment: Windows 7 Qt 5.5 MinGW 4.9 DMD 2.69.1 DUB (with dynamicLibrary option) Everything is x86. I am really stuck here. Thanks on beforehand. I'm surprised you're able to get an executable when

Re: Why does partial ordering of overloaded functions not take return type into account?

2016-02-20 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 20 February 2016 at 17:20:16 UTC, Mike Parker wrote: getValue(); It's not unusual to discard the return value when calling a function. Though a getter isn't a good example of this, of course. Oops. I somehow had it in my head that your example function was getValue(), rather

Re: Why does partial ordering of overloaded functions not take return type into account?

2016-02-20 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 20 February 2016 at 15:47:27 UTC, Jeremy DeHaan wrote: With the case of auto of course there is ambiguity, you don't know which one to pick. In my example there should have been no ambiguity at all as only one of the overloads would actually compile. That is what confuses me and

Re: Confusion regarding struct lifecycle

2016-02-15 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 16 February 2016 at 03:39:00 UTC, Matt Elkins wrote: On Tuesday, 16 February 2016 at 03:31:51 UTC, maik klein wrote: In D you can always call Foo.init even with @disable this(), Foo.init can be called implicitly (not just explicitly)? If so, why even have @disable this(), if it

Re: What is the best way to stop App after exception?

2016-02-15 Thread Mike Parker via Digitalmars-d-learn
On Monday, 15 February 2016 at 15:38:07 UTC, Suliman wrote: Since C's "exit" function is not liked, best thing you can do is to throw an Error when you want to close the program. You are not supposed to catch Errors. So, it eventually will stop the currently running thread. but if I throw

Re: D Book page 402 Concurrency FAIL

2016-02-14 Thread Mike Parker via Digitalmars-d-learn
On Monday, 15 February 2016 at 00:58:54 UTC, Brother Bill wrote: On Sunday, 14 February 2016 at 23:39:33 UTC, cym13 wrote: On Sunday, 14 February 2016 at 22:54:36 UTC, Brother Bill wrote: In "The D Programming Language", page 402, the toy program fails. [...] Can't reproduce with DMD

Re: joiner: How to iterate over immutable ranges?

2016-02-14 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 14 February 2016 at 19:32:31 UTC, Bastiaan Veelo wrote: Thanks. I didn't know that iterating a range means mutating its contents. I still don't quite get it, and it is probably because I don't fully understand ranges. I think what confuses me the most is their analogy to

Re: How to allocate arrays of objects?

2016-02-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 11 February 2016 at 04:07:18 UTC, cy wrote: The following program segfaults for me, compiling it with dmdv2.070 as well as the latest git. I must be doing it wrong. There's a way to specify class construction, or emplace, or something. But I can't find it! How do I deal with

Re: How to allocate arrays of objects?

2016-02-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 11 February 2016 at 04:31:12 UTC, cy wrote: Oh, I get it. `as` is an array of 2 pointers to A objects, both pointers set to null. So I need to say like: as[0..$] = new A(); before accessing .stuff on as[0]. Pedantically, no. It's an array of two class references. I don't

Re: Cannot get Derelict to work

2016-02-07 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 7 February 2016 at 12:55:30 UTC, Whirlpool wrote: Is it the same kind of problem as before ? If my understanding is correct [1], I need to link with the OpenGL DLL, don't I ? I found that I have an opengl32.dll file in C:\Windows\System32, and tried adding the path to it in the

Re: Cannot get Derelict to work

2016-02-07 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 7 February 2016 at 14:04:49 UTC, Mike Parker wrote: Another point to make is that if you need deprecated functions, DerelictGL3 is not what you want. You should import derelict.opengl3.gl and use DerelictGL.load/reload instead. It includes all of the deprecated functions. Just

Re: print function

2016-02-04 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 4 February 2016 at 10:18:35 UTC, ixid wrote: On Thursday, 4 February 2016 at 10:05:15 UTC, Jonathan M Davis wrote: I would normally expect someone to do that with writefln, which would be cleaner. e.g. writefln("%s %s %s %s", a, b, c, d); Personally, I've never felt the need for

Re: Binding to C - Arrays and Access Violation

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 04:19:37 UTC, jmh530 wrote: A few extra questions: 1) In other parts of the code I'm using extern(System), but that doesn't work for these. Why is extern(C) used for function pointers?, extern(C) is only used with function pointers when it's needed. It

Re: Cannot get Derelict to work

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 12:18:17 UTC, Whirlpool wrote: Hi, I'd like to use Derelict, more specifically the GLFW package, but so far I have been unable to make it work. (I posted in the IDE section but didn't get a reply (link below), and since the Derelict forum seems not to exist

Re: Cannot get Derelict to work

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote: latest release. Unfortunately, they do not provide a binary distribution, so you will have to build the DLL from source or find somewhere that makes it available prebuilt DLLs available for you. Actually, they do provide

Re: Cannot get Derelict to work

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 13:07:51 UTC, Mike Parker wrote: On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote: latest release. Unfortunately, they do not provide a binary distribution, so you will have to build the DLL from source or find somewhere that makes it

Re: Cannot get Derelict to work

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote: - First I tried to create a VisualD project on Windows, and to manually compile derelict-util and derelict-glfw3: FYI, this thread motivated me to revisit the manual compilation instructions in the Derelict docs [1]. I've

Re: Binding to C - Arrays and Access Violation

2016-02-02 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 2 February 2016 at 22:56:28 UTC, jmh530 wrote: My D code calls a C function. One of the parameters to the C function is a function pointer to a D function. This D function (below) is one that I copied from the C library's tutorial. I only slightly changed the signature. This

Re: D with DerelictASSIMP3 question

2016-02-01 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 2 February 2016 at 03:22:16 UTC, Maeriden wrote: Try aiGetMaterialTextureCount. I'm guessing derelict uses the C API as much as it can. It uses the C API exclusively.

Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 31 January 2016 at 03:45:01 UTC, Dsby wrote: Thanks, if I use the D dylib,I should run " rt_init(); " in every thread which i used the D dylib? No. rt_init only needs to be called once for the process. You need to call core.thread.attach_this [1] so that runtime is aware of

Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 31 January 2016 at 05:28:02 UTC, Mike Parker wrote: need to call core.thread.attach_this [1] so that runtime is Sorry, that's core.thread.thread_attachThis

Re: Overriding opEquals in classes, for comparison with things that aren't Objects

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 15:00:59 UTC, pineapple wrote: With this bit of code, the first method seems to work fine - things go as expected. But I get a compile error with the second method, and I'm not sure how else to write this. override bool opEquals(Object value) const{

Re: Why is it a memory ERRO.

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 13:22:07 UTC, Mike Parker wrote: Your problem is probably that you are calling GC.free in the destructor. Don't do this. You don't need to call GC.free at all. The GC will collect both your object instance and the memory you allocated with new. Never, ever,

Re: Why is it a memory ERRO.

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 12:43:53 UTC, Dsby wrote: the Code: ~this(){ GC.free(by.ptr); by = null; writeln("free"); } Your problem is probably that you are calling GC.free in the destructor. Don't do this. You don't need

Re: Dub packages: Best practices for windows support

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 19:46:40 UTC, Johannes Pfau wrote: Now on windows, things are more complicated. First of all, I can't seem to simply use "libs": ["foo"] as the linker won't find the C import .lib file. Then apparently there's no way to add a library search path with the MSVC

Re: Dub packages: Best practices for windows support

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 January 2016 at 01:17:13 UTC, Mike Parker wrote: There's an issue for this at [1]. Until support for -m32mscoff is baked in, distributing any libraries with a dub project will be problematic. [1] https://github.com/D-Programming-Language/dub/issues/628

Re: Dub packages: Best practices for windows support

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 January 2016 at 01:17:13 UTC, Mike Parker wrote: Hopefully one day dub will have the ability to pull down library dependencies on demand, or based on the current platform and architecture by default, then this problem goes away. I should say "precompiled library

Re: Can D interface with Free Pascal?

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 January 2016 at 03:43:59 UTC, Taylor Hillegeist wrote: Working through a simple example. I tried the cdecl option but for some reason i can compile but when i run my Gethello it cant find the shared library in the same folder? taylor@taylor-NE510:~/Projects/PASCAL$ nm

Re: Why is it a memory ERRO.

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 January 2016 at 05:50:33 UTC, Dsby wrote: Ok.Thank you. and i want to know how to know when the GC start runing? For the current implementation, any time you allocate memory through the GC it will determine if a collection cycle is needed, but it will not run otherwise.

Re: Can D interface with Free Pascal?

2016-01-28 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 28 January 2016 at 19:49:22 UTC, Taylor Hillegeist wrote: On Thursday, 28 January 2016 at 19:33:22 UTC, bearophile wrote: FreeSlave: On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote: Not directly. You can declare cdecl function on Free Pascal side and call it as

Re: free causes exception

2016-01-26 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 21:23:28 UTC, Igor wrote: um? Memory manager? I am doing it manually C++ style so I don't have to worry about the god forsaken memory manager. Why is it so difficult? I create the object and release it when I need to. He's talking about *your* memory manager,

Re: gtkd.lib: Error 43: Not a Valid Library File

2016-01-26 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 27 January 2016 at 01:20:49 UTC, Mike Parker wrote: has no connection library files has no relationship with library files What I mean is it is not used to specify libraries.

Re: gtkd.lib: Error 43: Not a Valid Library File

2016-01-26 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 22:30:24 UTC, Enjoys Math wrote: On Tuesday, 26 January 2016 at 22:10:42 UTC, Enjoys Math wrote: I get this message either compiling at command line -or- in VisualD. At command line when I add -m64, I get another error:

Re: how to allocate class without gc?

2016-01-25 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote: Is there any examples that shows how to properly allocate an object of a class type with the new allocators and then release it when desired? Allocate a block of memory big enough to hold an instance of your class using whichever

Re: New Win32 Core api broke?

2016-01-25 Thread Mike Parker via Digitalmars-d-learn
On Monday, 25 January 2016 at 22:57:22 UTC, Igor wrote: error LNK2019: unresolved external symbol GetStockObject referenced in function _D2Application10createWindowMFPFZvZi (int Application.createWindow(void function()*)) and the line of code is wc.hbrBackground =

Re: New Win32 Core api broke?

2016-01-25 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 05:05:43 UTC, Mike Parker wrote: the linker looked for its copied form *compiled* form

Re: `static` symbol needs to be `immutable` for compile-time access?

2016-01-22 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 January 2016 at 09:56:27 UTC, Shriramana Sharma wrote: In C/C++ the `static` here is used to avoid the array being created every time the function is entered; in D too it does the same thing, no? So if I have an array of constants in a function that I need to be accessible to a

Re: Linking C libraries with DMD

2016-01-21 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 January 2016 at 02:39:33 UTC, jmh530 wrote: The LearningD book says that you should compile the libraries with DMC on Windows, but I can't figure out how to generate a shared library on DMC. I didn't get the implib error for what I was working on before. I feel like getting

Re: Linking C libraries with DMD

2016-01-21 Thread Mike Parker via Digitalmars-d-learn
I've take your example, modified it slightly, compiled the DLL with Visual Studio, and got a working executable. Firs up, the C file. Here's your original: clib.c #include int some_c_function(int); int some_c_function(int a) { printf("Hello, D! from C! %d\n", a);

Re: Disabling GC in D

2016-01-21 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 21 January 2016 at 23:06:55 UTC, Dibyendu Majumdar wrote: On Thursday, 21 January 2016 at 22:44:14 UTC, H. S. Teoh wrote: Hi - I want to be sure that my code is not allocating memory via the GC allocator; but when shipping I don't need to disable GC - it is mostly a development

Re: Doubt - Static multidimension arrays

2016-01-19 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 08:27:56 UTC, tsbockman wrote: The only relevant difference between the two, is that the order of the row and column specification is swapped in *the declaration*, not when indexing. Newcomers to D tend to think in terms of C when they declare arrays, so the

Re: Doubt - Static multidimension arrays

2016-01-19 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 14:58:51 UTC, tsbockman wrote: Anyway, I'll give it a rest now. I thought this way of looking at it would make things easier to understand, but I guess not... In my experience, it's focusing on the types in the D array syntax, rather than the actual ordering,

Re: Doubt - Static multidimension arrays

2016-01-18 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 07:21:39 UTC, albert00 wrote: On Tuesday, 19 January 2016 at 04:50:18 UTC, tsbockman wrote: On Tuesday, 19 January 2016 at 03:20:30 UTC, albert00 wrote: [...] ... what you're making is an array *of arrays*: Maybe I was misunderstood, because in fact that is

Re: Doubt - Static multidimension arrays

2016-01-18 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 07:32:22 UTC, tsbockman wrote: That's because you're stuck in the mindset that 2d arrays are somehow *special*. If I do this: It's not that he's seeing them as special, it's just that indexing them in D is different than doing so in C or C++. It trips a lot

<    5   6   7   8   9   10   11   12   13   >