Re: How does calling function pointers work?

2018-11-12 Thread Mike Parker via Digitalmars-d-learn
On Monday, 12 November 2018 at 16:29:24 UTC, helxi wrote: Looks like worker needs an int and spawn(, i * 10) seems to feed it's second arg to worker(?) spawn is a template that takes a function pointer and a variable number of parameters. Both the pointer and the parameters are passed

Re: Why is stdio ... stdio?

2018-11-12 Thread Mike Parker via Digitalmars-d-learn
On Monday, 12 November 2018 at 10:10:37 UTC, bauss wrote: I just want to say everyone who doesn't use the web-interface has to look at markdown anyway because people still write code in backticks etc. despite no support; even I do that. Me, too. It's easy and unobtrusive. As for actually

Re: linker warnings and errors with bindbc-glfw

2018-11-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 November 2018 at 18:19:22 UTC, Dennis wrote: Both work, albeit with a lot of warnings: libcmt.lib(initializers.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library glfw3.lib(init.c.obj) : warning LNK4217: locally defined

Re: linker warnings and errors with bindbc-glfw

2018-11-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 November 2018 at 19:06:56 UTC, Dennis wrote: On Friday, 9 November 2018 at 18:19:22 UTC, Dennis wrote: [...] I just noticed in the section about the static version: "This requires the GLFW development package be installed on your system at compile time."

Re: Exception slipping through the catch block?

2018-11-08 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:50:38 UTC, helxi wrote: On Thursday, 8 November 2018 at 15:41:11 UTC, Adam D. Ruppe wrote: On Thursday, 8 November 2018 at 15:08:40 UTC, helxi wrote: Shouldn't the catch block in the function catch the exception? You caught Exception, but it throws Error.

Re: DirectX bindings

2018-10-30 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 30 October 2018 at 10:30:48 UTC, John Burton wrote: I want to do some graphics using direct3d11 on windows. There are some bindings that I used once before https://github.com/evilrat666/directx-d However they are marked as [discontinued] While I'm sure they will continue to work so

Re: Why is dynamic array length required here?

2018-10-18 Thread Mike Parker via Digitalmars-d-learn
On Friday, 19 October 2018 at 02:04:37 UTC, Samir wrote: I would have thought that since this is a dynamic array, I don't need to pre-assign its length. Thanks Just to expand on the previous answers, a dynamic array declaration with no initializer is an empty array: int[] arr;

Re: Noob question about structs allocation

2018-10-15 Thread Mike Parker via Digitalmars-d-learn
On Monday, 15 October 2018 at 04:14:24 UTC, IM wrote: What is the effect of calling destroy? - calling the destructor? - deallocating the memory? - both? It calls the destructor. The GC will deallocate the object's memory later. However, you need to be careful about how you use

Re: LDC2 -I option results in unresolved externals

2018-10-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 12 October 2018 at 06:01:12 UTC, spikespaz wrote: I'm using the latest LDC2 beta, and when running the compiler with -I (Look for imports also in ) it fails with unresolved externals. These are my commands. = $ ldc2

Re: Why are 2-D arrays reversed?

2018-10-10 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 10 October 2018 at 13:22:41 UTC, Chris Katko wrote: int[][] data = [ [1, 0, 1, 0, 0], [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 0, 0, 1, 0], [5, 1, 1, 1, 0] ]; when drawn with data[i][j],

Re: Does the WInMain function is mandatory ?

2018-09-30 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 30 September 2018 at 14:06:20 UTC, Vinod K Chandran wrote: Thanks. It worked. I would like to compile this as a gui. Now it starts with the cmd. Google search didn't gave me the link i want. Any help ? With the default OPTLINK linker: dmd -L/SUBSYSTEM:windows app.d In this

Re: Can I create static c callable library?

2018-09-26 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 26 September 2018 at 09:54:22 UTC, John Burton wrote: Is there any documentation anywhere that deals with calling D from C? I could find plenty the other way round. I think I'll give up on the idea though, and rewrite the whole thing in D :) Rewriting it in D is a great idea

Re: BetterC + Windows + setjmp longjmp

2018-09-17 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 18 September 2018 at 00:24:23 UTC, SrMordred wrote: Yes, i'm using signal(SIGSEGV, sigfn_t func), it catches correctly, but end the execution after. I find the alternatives of setjmp/longjmp and sigaction, but none are avaliable on windows afaik. setjmp/longjmp are available on

Re: Is it possible to translate this API's C headers?

2018-09-17 Thread Mike Parker via Digitalmars-d-learn
On Monday, 17 September 2018 at 03:16:33 UTC, spikespaz wrote: There is a project that I wish to use from D (https://ultralig.ht). It's Electron, but with forked WebKit and the samples are very, very fast. This is a great compromise between wanting to have a very custom interface and not

Re: linking trouble

2018-09-06 Thread Mike Parker via Digitalmars-d-learn
On Friday, 7 September 2018 at 02:44:24 UTC, hridyansh thakur wrote: On Thursday, 6 September 2018 at 16:59:43 UTC, rikki cattermole wrote: On 07/09/2018 4:03 AM, hridyansh thakur wrote: [...] That definition isn't complete. Missing at the very least ``();`` to make it a function

Re: Deduce type of struct in function arguments

2018-08-21 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 14:56:21 UTC, Seb wrote: I'm aware, but we don't have any other process for people to show their support for a DIP, do we? And for DMD/Druntime/Phobos etc. having a bunch of +1 helps a PR to move faster as we as reviewers can thus realize that this is sth.

Re: Deduce type of struct in function arguments

2018-08-21 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 08:32:17 UTC, Seb wrote: How and where to vote? At the pull request via +1 and the upcoming "official" discussion of the PR. Except that there's no voting process for DIPs. The Community Review is not intended as a way to vote, simply to provide feedback

Re: Auto keyword and when to use it

2018-08-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:24:19 UTC, QueenSvetlana wrote: I'm struggling to understand what the auto keyword is for and it's appropriate uses. From research, it seems to share the same capabilities as the var keyword in C#. auto is one of the most misunderstood understood features in

Re: Linking a C program with D library

2018-08-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 August 2018 at 02:40:22 UTC, Joe wrote: I understand that, Mike. However if I'm not mistaken given something in C like char* strs[] = { "This", "is a", "test"}; AFAIK, even with -betterC and an extern (C), the literals will still be understood by D as type "string", and

Re: Linking a C program with D library

2018-08-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 23:05:26 UTC, Joe wrote: I'm attempting a piecemeal conversion of some C programs. I've converted a few that depend on C modules that are in a library and now I'm sort of in the middle of converting those C modules. One of them has an array of strings, i.e., array

Re: Importing struct

2018-08-13 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:09:24 UTC, Andrey wrote: On Monday, 13 August 2018 at 13:05:28 UTC, evilrat wrote: however the best option is simply avoid naming anything with same name as module. Hmm, I thought that name of class should match name of file... And how to name a file that

Re: dmd64 on Windows: how?

2018-08-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 August 2018 at 19:50:30 UTC, Ivan Kazmenko wrote: n This was most close to solving my problem. Thanks! I've installed the components shown in wiki image: v141 tools and the SDKs. VS 2017 Community includes everything you need. There's no reason to install the SDK

Re: Could you anybody using DerelictSDL2 on Android?

2018-08-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 August 2018 at 14:36:59 UTC, zhani wrote: On Saturday, 11 August 2018 at 08:47:59 UTC, Mike Parker wrote: On Tuesday, 7 August 2018 at 12:05:33 UTC, zhani wrote: [...] I don't do any sort of Android development, so I've never tested any Derelict packages on the platform. A

Re: Could you anybody using DerelictSDL2 on Android?

2018-08-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 August 2018 at 15:46:47 UTC, tide wrote: extern(C) is a feature, Derelict are libraries. https://dlang.org/spec/interfaceToC.html You can use Derelict "static" to the same effect I think, but they way they achieve it doesn't play well with auto completion and such. All of

Re: Could you anybody using DerelictSDL2 on Android?

2018-08-11 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 7 August 2018 at 12:05:33 UTC, zhani wrote: howdy :-) can anybody use sdl2 on android? first, i got a ldc2 for android. i just followed here on windows: https://wiki.dlang.org/Build_D_for_Android#Windows so i could compile a sieve.d but didnt run it on android yet. then next?

Re: How to force console

2018-08-01 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 1 August 2018 at 20:57:30 UTC, Everlast wrote: I can create a console for a dll using AllocConsole and special Write functions but this is a pain. How do I get all standard input and output to either use this console or for the app to create the console automatically? The

Re: Windows 7 x64. Prevent appearing of console with GUI application

2018-07-24 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 24 July 2018 at 08:09:33 UTC, ANtlord wrote: Hello! I'm trying run my GUI application getting a console hidden. The application is on top of GTKD, compiled with dmd 2.081.1 in Windows 7 x64. I read a few threads on the forum and StackOverflow and I got that I need to add a module

Re: Windows 7 x64. Prevent appearing of console with GUI application

2018-07-24 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 24 July 2018 at 08:48:54 UTC, Mike Franklin wrote: Here's my test extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) When using WinMain, subsystem:windows is the default. The OP wants to use main as the entry point,

Re: Template variable not reach at compile

2018-07-21 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 21 July 2018 at 12:17:54 UTC, Greatsam4sure wrote: Sorry for the typo. This is the problem auto arithmetic(T, V, U)(T a, V b, U op){ return mixin("a"~op~"b"); } //call like this arithmetic(1.5,2.5,"+"); Compiler says the variable op is not reach at compile time. So how

Re: Windows 64-bit import library

2018-07-19 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 July 2018 at 04:31:38 UTC, Jordan Wilson wrote: I don't have MSVC, so I built it using mingw, which generated a .a lib. I shall google some more, as I understand it DMD -m64 uses Mingw libs as a fall back when MSVC not found, I compiled Lua using mingw, I can't be too much

Re: Windows 64-bit import library

2018-07-19 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 19 July 2018 at 21:43:35 UTC, Jordan Wilson wrote: Is there any way I can generate the appropriate lib? Else I think I'll need to get hold of the proper import libs that come with the Lua distribution. Lua is extremely easy to build. That will generate the import lib for

Re: Configuring DerelictGL3

2018-07-19 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 19 July 2018 at 00:27:58 UTC, Entity325 wrote: So I'm using the standard process: DerelictGL3.load(); glContext = SDL_GL_CreateContext(sdlWindow); GLVersion glVersion = DerelictGL3.reload(); About 1/3 of the time, the program hangs on the 3rd line and never gets past it.

Re: Why is it hard to make Qt bindings?

2018-07-05 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 July 2018 at 12:52:49 UTC, Steven Schveighoffer wrote: I remember there being a project for qt for D a long time ago. I think this is it: http://www.dsource.org/projects/qtd You may find some way to resurrect this. And QtE5 is still active. He announced support for QML not

Re: how to create an array of scoped objects ?

2018-07-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 14:42:58 UTC, Flaze07 wrote: On Tuesday, 3 July 2018 at 14:32:01 UTC, Mike Parker wrote: Resources allocated for the process will be released on exit. I see...but it is dependant on the OS right ? because I have seen other stuff relating to malloc as well, there

Re: Issues with undefined symbols when using Vibe on Windows

2018-07-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 13:32:21 UTC, Chris M. wrote: After hashing it out with some people on the Discord, I'm fairly certain we narrowed it down to the 64-bit user32.lib from mingw missing these functions. https://issues.dlang.org/show_bug.cgi?id=19051 So are the mingw libs only

Re: how to create an array of scoped objects ?

2018-07-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 10:56:26 UTC, Flaze07 wrote: hmm, I assume you know about DSFML, so... i.e void main( string args[] ) { auto win = new RenderWindow( VideoMode( 400, 400 ), "resource leak ?" ); win.close(); } //in this context, is there any memory leak ? because I saw

Re: how to create an array of scoped objects ?

2018-07-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 07:29:12 UTC, Flaze07 wrote: class RenderWindow { private sfRenderWindow* _window; public { this() { _window = sfRenderWindow_create(/*parameters*/); } //couple of other functions ~this() {

Re: Issues with undefined symbols when using Vibe on Windows

2018-07-02 Thread Mike Parker via Digitalmars-d-learn
On Monday, 2 July 2018 at 23:00:08 UTC, Chris M. wrote: On Monday, 2 July 2018 at 21:20:26 UTC, Seb wrote: I thought for 64-bit the bundled lld linker and mingw runtime are used? https://dlang.org/changelog/2.079.0.html#lld_mingw So in fact you shouldn't even need DMC? Ah, okay. I'm mostly

Re: Delegating constructor and call to super

2018-07-02 Thread Mike Parker via Digitalmars-d-learn
On Monday, 2 July 2018 at 09:42:36 UTC, Robert M. Münch wrote: I think it's because of "If a constructor's code contains a delegate constructor call, all possible execution paths through the constructor must make exactly one delegate constructor call" But, how am I supposed to call the

Re: Passing C++ class to DLL for callbacks from D (Steam)

2018-06-07 Thread Mike Parker via Digitalmars-d-learn
On Friday, 8 June 2018 at 00:55:35 UTC, cc wrote: class CImpl : CCallbackBase { extern(C++) { If anyone has any insight to provide it would be greatly appreciated, thanks! I've not used any of the C++ interfacing features yet, but my understanding is the extern(C++) has to apply

Re: Using stdin/out in a windows application bugs only when compiled to 64bit.

2018-06-07 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 7 June 2018 at 19:19:55 UTC, realhet wrote: Hi, The following narrow test program works fine when compiled with DMD to 32bit target: import std.stdio, core.sys.windows.windows, core.runtime; extern(Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR

Re: Configuring DerelictGL3

2018-06-06 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 7 June 2018 at 02:47:12 UTC, Entity325 wrote: I added the line, "mixin glContext!(GLVersion.gl33);" after the import statement. I didn't do anything with the context because I assumed SDL2 handled that, and creating my own would likely break the code. You aren't mixing

Re: question about keeeping reference to toStringz()

2018-05-30 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 31 May 2018 at 01:12:34 UTC, Dr.No wrote: is foo() is being called from a thread, how I am supposed to keep cstring "alive"? As Jonathan explained, you don't have to worry about it if foo() itself doesn't assign the pointer to anything internally. That will be the case for

Re: using wkhtmltopdf with D

2018-05-28 Thread Mike Parker via Digitalmars-d-learn
On Monday, 28 May 2018 at 21:05:00 UTC, Dr.No wrote: On Monday, 28 May 2018 at 02:10:48 UTC, sarn wrote: On Monday, 28 May 2018 at 01:28:10 UTC, Dr.No wrote: What's likely the reason of the crash? mismatch between D and C memory alignment? From an ABI point of view, the raw pointers won't

Re: Derelict on Ubuntu with CODE::BLOCKS

2018-05-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 May 2018 at 18:36:04 UTC, RegeleIONESCU wrote: And here is the error I get when I execute dub run: christian@Christians:~/D_Projects$ dub run Performing "debug" build using /usr/bin/dmd for x86_64. derelict-util 2.0.6: target for configuration "library" is up to date.

Re: Derelict on Ubuntu with CODE::BLOCKS

2018-05-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 May 2018 at 03:18:02 UTC, RegeleIONESCU wrote: The only problem I have with DUB is that all added dependencies are "old". For example added dependency "derelict-sdl2" is version="~>2.1.4" while on DUB site the last version is 3.1.0-alpha.3. I tried the --upgrade plus

Re: Program exited with code 1

2018-04-19 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 19 April 2018 at 11:21:52 UTC, Andrey wrote: On Thursday, 19 April 2018 at 08:37:19 UTC, Andrey wrote: What will be a solution? It seems to me that I found a solution - just replace WinMain() with main(). That's fine when you want a console app, but it leaves you with a

Re: How would you create this construct?

2018-03-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 30 March 2018 at 02:30:01 UTC, Chris Katko wrote: What I'm trying to do is through this experimental API, is both eliminate the user needing to call a clean-up function explicitly, and, make the "right way" to use the API basically... the only way... to use it. The way I have

Re: Building Derelict based application under windows

2018-03-22 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 22 March 2018 at 20:51:36 UTC, ANtlord wrote: Thanks in advance. Please feel free to ask any question Your errors with the derelict libs are linker errors, with the early ones being this one: "warning LNK4003: invalid library format; library ignored" At the top of the output,

Re: #import mapi.h

2018-03-22 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 22 March 2018 at 21:45:40 UTC, Martin Tschierschke wrote: On Thursday, 22 March 2018 at 17:42:46 UTC, Paul Backus wrote: On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: Is there an step by step introduction how to convert a C header of an external lib into

Re: Readonly field for class type

2018-03-15 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 15 March 2018 at 10:16:49 UTC, Andrey wrote: Hello, is there way to declare read only field for class type with ability to call inner non constant methods? i.e.: class A { int value = 12; void updateValue() { value = 13; } } class B { const A a;

Re: Readonly field for class type

2018-03-15 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 15 March 2018 at 10:55:16 UTC, Mike Parker wrote: class A { private int _value = 12; int value() @property { return _value; } void updateValue() { value = 13; } } ... auto a = new A(); writeln(a.value); a.updateValue(); writeln(a.value); Sorry. I overlooked that

Re: how to make private class member private

2018-03-13 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 09:14:26 UTC, psychoticRabbit wrote: That's make a little uncomfortable, given how long and complex modules can easily become(and aleady are) Is there a practical difference between a) a module that contains a class with 20 member functions all accessing

Re: how to make private class member private

2018-03-13 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 06:58:08 UTC, psychoticRabbit wrote: What you're saying, is in D, class encapsulation is really 'module' encapsulation. I get it. Fine. It's an intersting design decision. "Enapsulation" in D means the same as it does in every other language -- hidden from

Re: how to make private class member private

2018-03-13 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 05:11:48 UTC, psychoticRabbit wrote: 1st - D has broken the concept of class encapsulation, simply for convenience at the module level. Not good in my opinion. No, it hasn't broken encapsulation. Encapsulation is at the module level. A class or struct and any

Re: how to make private class member private

2018-03-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 05:35:30 UTC, Amorphorious wrote: There is another problem: 3rd: You are a brainwashed monkey who can't think for himself. No need for personal attacks. Let's keep it civil.

Re: how to make private class member private

2018-03-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 02:06:57 UTC, psychoticRabbit wrote: Mmm.. I don't think I like it. I feel you should be able to make a member of a class, private, regardless of where the class is located. This seems to break the concept of class encapsulation. No. I don't like it at all.

Re: can't build libuid examples

2018-03-06 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 19:19:05 UTC, greatsam4sure wrote: Try to build libuid examples get the following error. dub build, build successfully on the root folder. I will appreciate any help. Just try to build a gui app using dlang. OPTLINK (R) for Win32 Release 8.00.17 Those

Re: Template Class With Default Values

2018-03-04 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 4 March 2018 at 11:35:23 UTC, bauss wrote: Why is the following not working? class Foo(string baz = "baz") { mixin("int " ~ baz ~ ";"); } class Bar : Foo { } Shouldn't it implicit do, without me having to do it manually? class Bar : Foo!"baz" { } class Bar : Foo!() { }

Re: DerelictGL3 and glBegin() access violation.

2018-02-28 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 28 February 2018 at 16:47:49 UTC, Kayomn wrote: Yeah, I knew they were deprecated, just weren't aware Derelict doesn't load them. Thanks though, I'd been up and down the Derelict docs page and I didn't see anything about this. Yeah, I decided against documenting the older

Re: DerelictGL3 and glBegin() access violation.

2018-02-28 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 28 February 2018 at 12:02:27 UTC, Kayomn wrote: import derelict.opengl3.gl3; Whoa. Just noticed this. That's an older version of DerelictGL3 you're using there. You should really be using the latest version of both DerelictGL3 and DerelictGLFW3. The -alpha versions are what

Re: DerelictGL3 and glBegin() access violation.

2018-02-28 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 28 February 2018 at 12:02:27 UTC, Kayomn wrote: Is this a DerelictGL3 bug? Am I missing something else that I should be initializing? Other things like glClear() seem to be working fine. No, not a bug. glBegin is one of the deprecated OpenGL functions. DerelictGL3 these days

Re: Derelict GLFW3 and dynamic linking on Linux

2018-02-27 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 27 February 2018 at 12:00:20 UTC, Kayomn wrote: derelict.util.exception.SymbolLoadException@../../.dub/packages/derelict-util-2.0.6/source/derelict/util/exception.d(35): Failed to load symbol glfwSetWindowIcon from shared library /u sr/lib/x86_64-linux-gnu/libglfw.so.3.1 I was

Re: std.traits.isBoolean

2018-02-18 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 18 February 2018 at 14:52:37 UTC, Tony wrote: At https://dlang.org/library/std/traits/is_boolean.html it has: enum isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; per: https://dlang.org/library/std/traits/is_aggregate_type.html isAggregateType is true for [struct,

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:24:27 UTC, Mike Parker wrote: import std.stdio; enum numBytes = 12; void foo(T, size_t N)(T[N] arr) if((N * T.sizeof) == numBytes) { writeln(arr); } void bar(ubyte[12] arr) { writeln(arr); } Also, it's worth mentioning in case you

Re: uint[3] not equivalent to void[12]?

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 15:05:33 UTC, Ralph Doncaster wrote: This seems odd to me. Is there a way I can make a function that takes an array of any type but only of a specific size in bytes? void.d(8): Error: function void.foo (void[12] arr) is not callable using argument types

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 14:04:05 UTC, Dennis wrote: I added `pragma(lib, "mupen64plus.lib");` above the extern(C) block. Adding `libs "mupen64plus"` to dub.sdl doesn't make a difference. Where was the lib file located? Was it in the root project directory? How are you compiling your

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 12:15:04 UTC, Dennis wrote: I presume the .dll isn't loaded properly (if at all), but I can't find a load function in the .lib and don't know how to debug this. So I guess I'll just do it manually since that works, but does anyone have some tips to make .dll

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 February 2018 at 12:15:04 UTC, Dennis wrote: I found the IMPLIB tool (http://www.digitalmars.com//ctg/implib.html) and made a .lib for the .dll and at first I got: Error 42: Symbol Undefined _CoreGetAPIVersions Error: linker exited with status 1 Forgot to address this in the

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 8 February 2018 at 10:09:12 UTC, Timothee Cour wrote: I'm curious whether scope guards add any cost over the naive way, eg: ``` void fun(){ ... scope(success) {bar;} ... } ``` vs: ``` void fun(){ ... if(foo1){ bar; // add this before each return return; }

Re: Interfacing with C++

2018-02-04 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 4 February 2018 at 08:17:31 UTC, Mike Parker wrote: So assuming CV_CDECL is cdecl, this should do it: extern(C) alias CvCmpFunc = int function(const(void)*, const(void)*, void*); Assuming this is OpenCV, Looking at [1], it's cdecl only on Windows. Empty everywhere else. So

Re: Interfacing with C++

2018-02-04 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 4 February 2018 at 07:54:12 UTC, infinityplusb wrote: Hi all I'm looking to try and write an interface to C++, but given I'm a casual dabbler in D, it's slightly beyond my current ability in terms of both C++ and D! As a leg up, how would one translate something like this from

Re: Don't expect class destructors to be called at all by the GC

2018-01-31 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 31 January 2018 at 10:14:53 UTC, DanielG wrote: Pardon my probable ignorance (D newbie and all), but why wouldn't a 'delete' work for this? https://dlang.org/spec/expression.html#delete_expressions delete is deprecated: https://dlang.org/deprecate.html#delete

Re: Is it possible to obtain textual representation of an arbitary code?

2018-01-26 Thread Mike Parker via Digitalmars-d-learn
On Friday, 26 January 2018 at 11:18:21 UTC, Oleksii Skidan wrote: I could imagine a mixin-based solution in D: ```d // Usage: ASSERT!"a == b"; ``` But it seems a bit alien to me. First of all, it kind of stringly-typed one. Secondly, neither IDEs nor advanced text editors are able to figure

Re: static weirdness

2018-01-25 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 25 January 2018 at 12:58:12 UTC, Jonathan M Davis wrote: Thinking about it, I do vaguely recall a discussion sometime last year about an invariant being invisibly inserted under some set of circumstances. Maybe that's what's happening? I believe that it was complained about in

Re: SegFault with HibernateD

2018-01-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 12 January 2018 at 08:55:13 UTC, Rene Zwanenburg wrote: It looks to me like the program is being run through dub, and dub is just reporting the program's exit code. I see now. I glossed right over that execution output. On Windows, I don't recall ever seeing a dub exception

Re: SegFault with HibernateD

2018-01-11 Thread Mike Parker via Digitalmars-d-learn
On Friday, 12 January 2018 at 05:24:52 UTC, Venkat wrote: I get a SegFault with the main method below which uses HibernateD . The second main method which uses ddbc just works fine. What is wrong with the first main method ? I have attached the error at the bottom although I don't think it

Re: DerelictGL3 glGenBuffers segmentation fault.

2017-12-24 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 24 December 2017 at 14:48:20 UTC, Kevin wrote: Thanks. That help but know my buffers doesn't recognize opengl types. I created mygl and import it to all files. Updated code on github. source/buffers.d(6,12): Error: undefined identifier GLuint, did you mean alias GLuint64?

Re: DerelictGL3 glGenBuffers segmentation fault.

2017-12-23 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 24 December 2017 at 05:23:12 UTC, Mike Parker wrote: If you are going to use glFreeFuncs like this, you can't import opengl that way. As per the DerelictGL3 documentation [1], the simplest way to make this work is to implement a module that publicly imports derelict.opengl and

Re: DerelictGL3 glGenBuffers segmentation fault.

2017-12-23 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 24 December 2017 at 03:00:16 UTC, Kevin wrote: On Sunday, 24 December 2017 at 01:42:58 UTC, Mike Parker wrote: I've found the problem. But first... I making a simple static library. I don't see a static library anywhere. You weren't "importing a static library", something which

Re: DerelictGL3 glGenBuffers segmentation fault.

2017-12-23 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 24 December 2017 at 00:58:25 UTC, Kevin wrote: When I import my library into my program. glGenBuffers segmentation fault. When I copy VertexBuffer into main code. It works fine. Why am I getting segmentation fault from library ? Need more info than this. Some code that

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 December 2017 at 00:09:31 UTC, Mike Franklin wrote: What condition(s) would cause a destructor for an object that is managed by the GC to potentially not be called? Here: === import std.stdio; class Clazz { ~this() { writeln("Class dest"); } } void

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 21 December 2017 at 14:26:55 UTC, Guillaume Piolat wrote: On Thursday, 21 December 2017 at 06:50:44 UTC, Mike Parker wrote: That's what I've taken to doing manually, by implementing a `terminate` function in my classes that I either call directly or via a ref-counted templated

Re: Don't expect class destructors to be called at all by the GC

2017-12-20 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 21 December 2017 at 04:10:56 UTC, user1234 wrote: On Thursday, 21 December 2017 at 02:57:00 UTC, Mike Franklin Unfortunately, that doesn't really shed much light on this oddity. So, specifically, under what circumstances are destructors not called? When the GC is unaware

Re: Clarity about extern(Windows)/extern(System)

2017-12-18 Thread Mike Parker via Digitalmars-d-learn
On Monday, 18 December 2017 at 14:31:38 UTC, Kagamin wrote: https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/x86-Function-Attributes.html#index-functions-that-pop-the-argument-stack-on-x86-32-3 looks like gcc doesn't see it as OS dependent. Thanks. I was playing around on asm.dlang.org and found

Re: Clarity about extern(Windows)/extern(System)

2017-12-18 Thread Mike Parker via Digitalmars-d-learn
On Monday, 18 December 2017 at 10:52:22 UTC, Kagamin wrote: On Sunday, 17 December 2017 at 13:36:15 UTC, Mike Parker wrote: My limited testing on a 64-bit Linux VM shows no problems when binding a C function as extern(C) or extern(Windows), and the disassembly looks the same. 64-bit ABI

Re: Write native GUI applications for Windows

2017-12-18 Thread Mike Parker via Digitalmars-d-learn
On Monday, 18 December 2017 at 07:55:25 UTC, Andrey wrote: Hello! I have a question about creating native GUI applications for Windows 7 or/and Windows 10. I know that exist DWT, DlangUI and other... But I'm interesting in native GUI. If it will be C++ then I would use WinAPI from SDK. And

Clarity about extern(Windows)/extern(System)

2017-12-17 Thread Mike Parker via Digitalmars-d-learn
For years now, I've been under the impression that the distinction between extern(Windows) and extern(System) actually mattered. I recall extern(System) was first added to the language to resolve this situation for C bindings: version(Windows) extern(Windows): else extern(C): Which, or

Re: Dub generates a library file that is larger in size than the one built on command line.

2017-12-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 17 December 2017 at 02:42:44 UTC, Venkat wrote: dub build --vverbose That is the command I used. Would it be right to assume that -g is being added because --vverbose ? The reason I ask is the file size is about the same when I run the below command. dub build It's because

Re: Pass D const pointer to opaque C library: Guarantees? Optimization-safe?

2017-12-16 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 16 December 2017 at 11:19:36 UTC, Mike Parker wrote: I would expect SiegeLord to reject such a PR. And now that I clicked through the link, I see I was wrong :-) In principle, I disagree with him because of what I mentioned above about immutable variables. In practice, it's

Re: Pass D const pointer to opaque C library: Guarantees? Optimization-safe?

2017-12-16 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 16 December 2017 at 08:56:59 UTC, SimonN wrote: Hi, I'm calling a C library through a D wrapper. The situation is like this: C library has: struct A { ... }; A* create_a() { ... } void foo(A*) { ... } D wrapper declares: extern (C) { struct A {}

Re: How to statically link Derelict SDL2 satellite libs

2017-12-14 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 14 December 2017 at 15:07:12 UTC, eskaypee wrote: On Thursday, 14 December 2017 at 14:45:51 UTC, Mike Parker wrote: Yes, you need to link with SDL_image. Sorry Mike, just noticed the end of my original question was missing: I have SDL_Image installed (dev version) but can't see

Re: How to statically link Derelict SDL2 satellite libs

2017-12-14 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 December 2017 at 20:59:41 UTC, eskaypee wrote: I'm on Linux 64 bit, all SDL libraries (-dev versions) are installed, dub is set up with: "dependencies": { "derelict-sdl2": "~>3.0.0-beta" }, "subConfigurations": { "derelict-sdl2": "derelict-sdl2-static"

Re: Derelict on Ubuntu with CODE::BLOCKS

2017-12-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 December 2017 at 16:50:10 UTC, RegeleIONESCU wrote: Hello! Please help me install and use Derelict on Ubuntu 16.04! I saw this tutorial https://www.youtube.com/watch?v=exQ43PFWJBU and I wanted to do it in D but I got lost, totally lost. First step is to import OpenGL via

Re: std.conv.to!string refuses to convert a char* to string.

2017-12-09 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:14:36 UTC, Venkat wrote: Thanks for the quick response. std.string.fromStringz did the trick. I am not sure what was the deal with to!string. Be careful with fromStringz. It doesn't allocate a new string, so the returned string can easily become corrupted if

Re: Any derelict fmod users on Linux out there?

2017-12-07 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 7 December 2017 at 22:57:20 UTC, WhatMeWorry wrote: I've tried debugging this for hours to no avail. It works on Windows and Mac fine. But I'm running Antergos Linux (very much like Arch) and it keeps failing at the System Init line. The code is pretty much a copy of the example

Re: Problem getting Cimgui to work

2017-12-06 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 21:21:11 UTC, Thomas wrote: Hi folks! I got it to work, but honestly I don't know why.. :-) Glad you got it working. I wanted to reply earlier but I was on my phone when I first saw this thread. So now instead of helping you solve the problem, I'll throw in

Re: Linking multiple libraries

2017-11-25 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 25 November 2017 at 22:43:30 UTC, A Guy With a Question wrote: Actually ignore that last comment, they are producing libs not dlls. Funny how all three ways of linking work... On Windows, when building a DLL, compilers typically produce an "import library" alongside it, which

Re: Linking multiple libraries

2017-11-25 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 25 November 2017 at 22:18:52 UTC, A Guy With a Question wrote: That's how I set up the linking in Visual D. Everything builds. But should the final exe try to link against all 3 libraries, library 3 link to library 1 & 2 and library 2 link to library 1 (also builds)? Or is the

Re: Range violation

2017-11-24 Thread Mike Parker via Digitalmars-d-learn
On Friday, 24 November 2017 at 09:59:13 UTC, Vino wrote: if (args.length < 1 || args.length > 2) { writeln(args[0].baseName, ":No Arguments Provided"); exit(-1); } When you pass no arguments, this won't execute as args.length will still be 1, the only argument

<    1   2   3   4   5   6   7   8   9   10   >