Linking to -framework on MacOS

2019-09-04 Thread Andrew Edwards via Digitalmars-d-learn
Hello, I'm trying to link to "-framework OpenGL" on MacOS and finding any clues on how to accomplish this. If I pass that switch to clang and use clang to create the executable, it works perfectly but I would like to use dmd to create the executable. Here is the list of errors I'm trying to

Re: Linking to -framework on MacOS

2019-09-04 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 4 September 2019 at 15:05:46 UTC, rikki cattermole wrote: Four years ago, I was linking against Cocoa via: "lflags-osx": ["/System/Library/Frameworks/Cocoa.framework/Cocoa"], I don't know if this will help you or not. Worked like a charm: -L/System/Library/Frameworks/Cocoa.f

Re: Linking to -framework on MacOS

2019-09-04 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 4 September 2019 at 15:22:51 UTC, Adam D. Ruppe wrote: On Wednesday, 4 September 2019 at 15:00:52 UTC, Andrew Edwards wrote: Could someone point me in the right direction please? You can also add `-L-framework -LCocoa` to dmd to pass the two arguments to the linker (they need to

Re: getting rid of immutable (or const)

2019-09-05 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 5 September 2019 at 08:16:08 UTC, Daniel Kozak wrote: On Thu, Sep 5, 2019 at 9:55 AM berni via Digitalmars-d-learn wrote: I still struggle with the concept of immutable and const: > import std.stdio; > > void main() > { > auto p = Point(3); > auto q = p.x; > writeln(t

Re: Linking to -framework on MacOS

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 5 September 2019 at 12:30:33 UTC, Jacob Carlborg wrote: On 2019-09-04 17:12, Andrew Edwards wrote: Worked like a charm:  -L/System/Library/Frameworks/Cocoa.framework/Cocoa This probably not a good idea. It relies on how a framework is structured internally. Adam's solution is

Re: Linking to -framework on MacOS

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 5 September 2019 at 18:26:41 UTC, DanielG wrote: And depending on the version of macOS / which framework you're linking to, you might need to specify a search path as well (-F): lflags "-framework" "SomeFramework" "-framework" "AnotherFramework" "-F/Library/Frameworks" IIRC I d

C++ vs D: Default param values and struct to array casting

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float _d) { a = _a; b = _b; c = _c; d = _d; } float operator[]

Re: C++ vs D: Default param values and struct to array casting

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 09:14:31 UTC, Andrew Edwards wrote: C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float _d) { a = _a; b = _b;

Re: C++ vs D: Default param values and struct to array casting

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 09:49:33 UTC, Johan Engelen wrote: On Friday, 6 September 2019 at 09:14:31 UTC, Andrew Edwards wrote: C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float _d

Re: C++ vs D: Default param values and struct to array casting

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 11:35:59 UTC, a11e99z wrote: https://dlang.org/spec/simd.html This didn't work two well because I wont be able to access the members by name as C++ library expects. Will consider during refactoring. also probably u can do https://run.dlang.io/is/WMQE93 End

Re: C++ vs D: Default param values and struct to array casting

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 18:31:29 UTC, Ali Çehreli wrote: On 09/06/2019 02:14 AM, Andrew Edwards wrote: > I'm seeking some pointers on how to define these in D Here is my attempt: Ali, this is awesome. It solves all 4 problems in on shot. I definitely don't intend on using the undefin

Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
I'm running into the following issue when attempting to interface with C++: // C++ namespace MySpace { MyType& GetData(); } struct MyType { // ... float continuallyUpdatedValue; // ... }; // call site MySpace::GetData().continuallyUpdatedValue; // D extern (C

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:24:49 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > float continuallyUpdatedValue; > float continuallyChangingValue; // [1] They mean the same thing for an English speaker but compilers don't know that (yet?). :) Ali L

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:30:53 UTC, Andrew Edwards wrote: On Saturday, 7 September 2019 at 12:24:49 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > float continuallyUpdatedValue; > float continuallyChangingValue; // [1] They mean the same thing for

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:39:25 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > [1] I did not declare any of the other member variables from the struct, > don't know if this is a source of the problem. Yes, it definitely is a problem. The members are accessed a

Request assistance initializing struct instance at global scope

2020-12-06 Thread Andrew Edwards via Digitalmars-d-learn
Given: === extern(C): char*[] hldr; enum I = (1<<0); struct S { char* ft; char** fm; int f; } void main(){} === How do I initialize an instance of S at global scope? // Not sure how to do this... so try to keep as close to original as possible // Nope, does not work S

Re: Request assistance initializing struct instance at global scope

2020-12-07 Thread Andrew Edwards via Digitalmars-d-learn
On 12/7/20 10:12 PM, Jacob Carlborg wrote: On Monday, 7 December 2020 at 04:13:16 UTC, Andrew Edwards wrote: You can either use `extern(C) char*[] hldr` to make only `hldr` have C linkage. Use `extern(C) {}` to group several symbols which should have C linkage or rearrange the code so that `st

Re: Request assistance initializing struct instance at global scope

2020-12-07 Thread Andrew Edwards via Digitalmars-d-learn
On 12/7/20 10:56 PM, Adam D. Ruppe wrote: On Monday, 7 December 2020 at 04:13:16 UTC, Andrew Edwards wrote: Given: === extern(C): char*[] hldr; Why is this extern(C)? A D array ere is probably wrong. To stay as close to the original implementation as possible. This will all cha

Request some GtkD Assistance

2019-03-27 Thread Andrew Edwards via Digitalmars-d-learn
Good day all, I've installed Gtk+ and GtkD on my MacBookPro which is running macOS Mojave but am having some issues linking to and using it. Any assistance to resolve this is appreciated. Steps taken: 1. Install Gtk+ brew install gtk+ 2. Build and install GtkD-3.8.5 unzip GtkD-

Re: Request some GtkD Assistance

2019-03-27 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 27 March 2019 at 09:07:37 UTC, Nicholas Wilson wrote: On Wednesday, 27 March 2019 at 06:55:53 UTC, Andrew Edwards wrote: dmd -de -w -Llibgtkd-3.a nufsaid try dmd -de -w -lgtkd-3 nufsaid No. That did not work. dmd -de -w -L/path/to/lib nufsaid This would is already include

Re: Request some GtkD Assistance

2019-03-28 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 27 March 2019 at 19:18:17 UTC, Mike Wey wrote: That because of the way the dmd and the linker interpret the arguments. -L tell dmd to pass the command that follows to the linker. To tell the linker to link with a library in a known location you would use the -l flag. For the

Basic Linear Algebra and D's Array Operation

2019-05-18 Thread Andrew Edwards via Digitalmars-d-learn
Sooo... I'm trying to learn this stuff so that I can fully grasp the content of Jens Mueller's 2019 DConf talk and its applications in financial sector (forex and options/futures trading). Unfortunately, I'm doing so using python but I'd like to accomplish the same in D. Here goes: Array (Vec

Re: Basic Linear Algebra and D's Array Operation

2019-05-19 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 19 May 2019 at 10:07:35 UTC, Alex wrote: On Sunday, 19 May 2019 at 06:34:18 UTC, Andrew Edwards wrote: So the question is, how do I pull this off in D using just builtin arrays and phobos? Any assistance is appreciated. Slice operations exist, but they are defined mainly for ar

Re: Basic Linear Algebra and D's Array Operation

2019-05-19 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 19 May 2019 at 17:13:11 UTC, Alex wrote: The operation itself is, however, a simple one. To implement a basic version I would cite http://rosettacode.org/wiki/Matrix_multiplication#D This is awesome. Thank you very much. Andrew

rdmd vs dmd WRT static constructors

2017-07-08 Thread Andrew Edwards via Digitalmars-d-learn
RDMD does not behave the same as DMD WRT static constructors. The following example, extracted form Mike Parker's "Learning D", does not produce the same result: // stat1.d module stat1; import std.stdio; static this() { writeln("stat1 constructor"); } // stat2.d module stat2; import std.stdio

Re: rdmd vs dmd WRT static constructors

2017-07-08 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 9 July 2017 at 03:11:17 UTC, Mike Parker wrote: On Sunday, 9 July 2017 at 02:57:54 UTC, Andrew Edwards wrote: To include stat1.d and stat2.d in the compilation, you'll either have to import them in statmain.d or use the --extra-file command line switch: rdmd --extra-file=stat1.d -

Re: Help me fix my compiler

2017-07-12 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:05:17 UTC, Namal wrote: Hello, I used the Install Script command line to install the newest dmd compiler (Ubuntu 16.04.2 LTS). Now I have to type 'source ~/dlang/dmd-2.074.1/activate' before I can use it and it is also not show in the software center like it u

How does one determine the UDAs of all symbols contained in a given module?

2017-07-19 Thread Andrew Edwards via Digitalmars-d-learn
Given a module (somepackage.somemodule) how does one programmatically determine the symbols contained therein and associated UDAs? Where symbol is a variable, function, UDT, etc... is this possible? foreach (symbol; somepackage.somemodule) { writeln(symbol.name, " attributes :")

Re: How does one determine the UDAs of all symbols contained in a given module?

2017-07-19 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 11:28:30 UTC, Jacob Carlborg wrote: On 2017-07-19 11:25, Nicholas Wilson wrote: You'll want to use https://dlang.org/spec/traits.html#getMember in conjunction with https://dlang.org/spec/traits.html#getAttributes. Have a look some of the projects on github e.g.

Re: How does one determine the UDAs of all symbols contained in a given module?

2017-07-20 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 14:23:25 UTC, Jacob Carlborg wrote: Here's an example: Thanks... Minus the AliasSeq bit, this is pretty much what I've been working with since talking to Brain. The main problem I'm facing is that it fails to compileif any of the symbols in the imported module

OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
int main() { //int wierd[4]; struct nk_color str = nk_rgba_hex("#deadbeef"); //int wierd[4]; char *s; //int wierd[4]; nk_color_hex_rgb(s, str); //int wierd[4]; printf("(%d,%d,%d)\n",str.r, str.g, str.b); //int wierd[4]; printf("%s\n", s); //int wierd[4];

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Andrew Edwards wrote: int main() { //int wierd[4]; struct nk_color str = nk_rgba_hex("#deadbeef"); //int wierd[4]; char *s; //int wierd[4]; nk_color_hex_rgb(s, str); //int wierd[4]; printf("(%d,%d,%d)\n",str.r, str.g, str.b); //int wierd[4]; printf("%s\n",

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Steven Schveighoffer wrote: On 8/3/17 9:12 PM, Andrew Edwards wrote: Andrew Edwards wrote: Just in case... here are the two functions being called in main(): https://github.com/vurtun/nuklear/blob/master/nuklear.h#L5695-L5722 Can you show how you declared these in D? It's important. I think

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Ali Çehreli wrote: On 08/03/2017 06:02 PM, Andrew Edwards wrote: char *s; That's an uninitialized C string. OK, I was is indeed the problem. I was thinking for some reason that s gets initialized inside nk_color_hex_rgb() but it's expecting to an array to work with. I actually noticed

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Steven Schveighoffer wrote: On 8/3/17 10:14 PM, Andrew Edwards wrote: I certainly can, but the problem is completely in C, I'm not having any problems in D. In this case, I've simply copied the two functions to test.c and inserted main(). Oh. Then Ali is correct. I assumed that char *s was in

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Ali Çehreli wrote: On 08/03/2017 06:02 PM, Andrew Edwards wrote: char *s; That's an uninitialized C string. OK, I was is indeed the problem. I was thinking for some reason that s gets initialized inside nk_color_hex_rgb() but it's expecting to an array to work with. I actually noticed

DUB dependency issue

2017-10-03 Thread Andrew Edwards via Digitalmars-d-learn
Attempting to use iopipe but not sure what I'm doing incorrectly I've cloned the repository in /Users/edwarac/git.repo.dir/ then added the path to dub: edwarac-pc:.dub edwarac$ dub add-path /Users/edwarac/git.repo.dir edwarac-pc:.dub edwarac$ dub list Packages present in the system and known to

Re: DUB dependency issue

2017-10-03 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 4 October 2017 at 01:59:48 UTC, Andrew Edwards wrote: Attempting to use iopipe but not sure what I'm doing incorrectly Finally figured it out. For some reason, the init find the local dependency to load but simply adding it to the dub.json afterward resolves the issue.

What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
A bit of advice, please. I'm trying to parse a gzipped JSON file retrieved from the internet. The following naive implementation accomplishes the task: auto url = "http://api.syosetu.com/novelapi/api/?out=json&lim=500&gzip=5";; getContent(url) .data .u

Re: What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 13 October 2017 at 19:17:54 UTC, Steven Schveighoffer wrote: On 10/13/17 2:47 PM, Andrew Edwards wrote: A bit of advice, please. I'm trying to parse a gzipped JSON file retrieved from the internet. The following naive implementation accomplishes the task: auto url = "http://a

Re: What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 13 October 2017 at 20:17:50 UTC, Steven Schveighoffer wrote: On 10/13/17 3:17 PM, Steven Schveighoffer wrote: this should work (something like this really should be in iopipe): while(input.extend(0) != 0) {} // get data until EOF This should work today, actually. Didn't think abo

Re: What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 13 October 2017 at 21:53:12 UTC, Steven Schveighoffer wrote: On 10/13/17 4:27 PM, Andrew Edwards wrote: On Friday, 13 October 2017 at 19:17:54 UTC, Steven Schveighoffer wrote: On 10/13/17 2:47 PM, Andrew Edwards wrote: A bit of advice, please. I'm trying to parse a gzipped JSON file

Re: What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 13 October 2017 at 22:29:39 UTC, Steven Schveighoffer wrote: It might be tough to do it right, but moot point now, since it's not necessary anyway :) -Steve Yup. Thanks again. Andrew

What's the best way to programmatically detect the most recent release of DMD and others?

2017-10-16 Thread Andrew Edwards via Digitalmars-d-learn
The best way I know to determine the latest DMD release is http://ftp.digitalmars.com/LATEST. I'm not aware that such a file exists for LDC and GDC so I'm currently doing: string latest(string url) { return executeShell("git ls-remote --tags " ~ url ~ " | cut -d 'v' -f 2 | cut -d '-' -f 1

Re: What's the best way to programmatically detect the most recent release of DMD and others?

2017-10-16 Thread Andrew Edwards via Digitalmars-d-learn
On Monday, 16 October 2017 at 18:21:46 UTC, Jacob Carlborg wrote: On 2017-10-16 17:13, Andrew Edwards wrote: Is there a better way? The official download script [1] is using the following: You're a godsend. Thank you very much.

Generating DDOX documentation

2017-10-20 Thread Andrew Edwards via Digitalmars-d-learn
Given a documented source file (eg. process.d), I can generate the DDOC version of the documentation with the -D switch of DMD as such: $ dmd -Dfprocess.html process.d What do I modify on that line to get the DDOX version of the same file? Thanks, Andrew

Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-07 Thread Andrew Edwards via Digitalmars-d-learn
I'm having a little bit of problem calling D code from C++ and would appreciate some assistance. First, given the following C++ program wich compiles, links, and runs without any problem: == // example.h SOME_API void foo(const char* str); // example.cpp

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-07 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 07:06:39 UTC, Nicholas Wilson wrote: On Wednesday, 8 November 2017 at 06:34:27 UTC, Andrew Edwards wrote: I'm having a little bit of problem calling D code from C++ and would appreciate some assistance. First, given the following C++ program wich compiles, links

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 07:30:34 UTC, evilrat wrote: On Wednesday, 8 November 2017 at 06:34:27 UTC, Andrew Edwards just using fully qualified name didn't make it? void call_cpp() { ::foo("do great things"); // calling global foo return; } No, it did not. Are you sure you p

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 15:12:05 UTC, MGW wrote: The useful material. https://www.youtube.com/watch?v=HTgJaRRfLPk Useful indeed, thank you.

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 08:42:01 UTC, Petar Kirov [ZombineDev] wrote: Walter has recently been working on improving the C++ mangling, so be sure to test the latest dmd nightly build and if that doesn't work be sure to file bug report(s). https://github.com/dlang/dmd/pull/7250 https:

Re: std.functional.compose compilation error

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 9 November 2017 at 04:58:19 UTC, Chuck Allison wrote: Chuck Allison Sorry to hijack this thread but it shan't be helped. Chuck, how is it going? Curious about the status of "Thinking in D". How do I go about participating in the draft review? -- Andrew

Re: std.functional.compose compilation error

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 9 November 2017 at 05:07:33 UTC, Andrew Edwards wrote: On Thursday, 9 November 2017 at 04:58:19 UTC, Chuck Allison wrote: Chuck Allison Sorry to hijack this thread but it shan't be helped. Chuck, how is it going? Curious about the status of "Thinking in D". How do I go about pa

C Macro deeper meaning?

2016-01-30 Thread Andrew Edwards via Digitalmars-d-learn
If I understand correctly, this piece of code: enum NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0) can be converted to the following in D: void notUsed(T)(T v) { return cast(void)0; }; since it always returns cast(void)0 regardless of the input. But it cannot be tha

Re: C Macro deeper meaning?

2016-01-30 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 31 January 2016 at 03:13:46 UTC, Adam D. Ruppe wrote: On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote: But it cannot be that simple, so what am I missing? I'm guessing the macro was there in C to silence compiler warnings about not using a return value. So I think

Alternate databases

2016-02-20 Thread Andrew Edwards via Digitalmars-d-learn
I'm searching for client drivers for the following databases. Are the any available? https://rethinkdb.com/docs/install-drivers/ http://docs.basho.com/riak/latest/dev/references/client-implementation/ Thanks, Andrew

Re: Alternate databases

2016-02-22 Thread Andrew Edwards via Digitalmars-d-learn
On 2/21/16 12:23 AM, yawniek wrote: On Saturday, 20 February 2016 at 13:09:53 UTC, Andrew Edwards wrote: I'm searching for client drivers for the following databases. Are the any available? https://rethinkdb.com/docs/install-drivers/ http://docs.basho.com/riak/latest/dev/references/client-imple

Re: Error with associative array initializer DMD32 D Compiler v2.070.0

2016-03-03 Thread Andrew Edwards via Digitalmars-d-learn
On 3/3/16 7:01 PM, MGW wrote: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; The only way this can be done outside the body of a function is if it is a manifest constant. This works: enum long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ];

Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has not specified one: #ifndef MIN #define MIN 99 #endif #ifndef MAX #define MAX 999 #endif I'm at

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 8:00 AM, H. S. Teoh via Digitalmars-d-learn wrote: On Fri, May 13, 2016 at 07:51:17AM +0900, Andrew Edwards via Digitalmars-d-learn wrote: The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has

imports && -run [Bug?]

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
module mod; // import inc; [1] // import inc: p=print; [1] // static import inc; [1] void main() { // import inc: print; // [2] print(); // static import inc; // [3] // inc.print(); } -- module inc; /*public*/ void print() // [4] { import std.std

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 8:40 AM, Andrew Edwards wrote: That seems wrong. You can't assign to an enum. Besides, doesn't your declaration of MIN shadow whatever other definitions may be currently in effect? Okay, got it. It seams I just hadn't hit that bug yet because of other unresolved issues. Perhaps wha

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 7:51 AM, Andrew Edwards wrote: The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has not specified one: #ifndef MIN #define MIN 99 #endif #ifndef MAX #define MAX 9

Re: imports && -run [Bug?]

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 3:10 PM, tsbockman wrote: On Friday, 13 May 2016 at 01:16:36 UTC, Andrew Edwards wrote: command: dmd -run mod inc output: Undefined symbols for architecture x86_64: "_D3inc5printFZv", referenced from: __Dmain in mod.o ld: symbol(s) not found for architecture x86_64 clang: er

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 3:23 PM, tsbockman wrote: On Friday, 13 May 2016 at 06:05:14 UTC, Andrew Edwards wrote: Additionally, what's the best way to handle nested #ifdef's? Those that appear inside structs, functions and the like... I know that global #ifdef's are turned to version blocks but versions blocks

Re: Request assistance converting C's #ifndef to D

2016-05-13 Thread Andrew Edwards via Digitalmars-d-learn
On 5/14/16 12:35 AM, Steven Schveighoffer wrote: On 5/13/16 12:59 AM, Andrew Edwards wrote: On 5/13/16 8:40 AM, Andrew Edwards wrote: That seems wrong. You can't assign to an enum. Besides, doesn't your declaration of MIN shadow whatever other definitions may be currently in effect? Okay, got

Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
http://ftp.dlang.org/ctg/implib.html The above URL suggests that, on Windoze, I can create a D compatible lib from a dll file by issuing the command: implib /s dsound.lib dsound.dll The following file: sound.d === pragma(lib, "dsound") struct IDirectSound{}; alias

Re: Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 27 May 2016 at 12:30:50 UTC, Guillaume Piolat wrote: On Friday, 27 May 2016 at 12:26:19 UTC, Andrew Edwards wrote: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html sound.obj(s

Re: Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 27 May 2016 at 16:08:27 UTC, Kagamin wrote: On Friday, 27 May 2016 at 15:28:42 UTC, Andrew Edwards wrote: Have you tried with extern(C) yet? extern(C) is for undecorated symbold extern(Windows) adds the _ and @12 decorations (would be __stdcall on C/C++ side) The thought never cros

Re: Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 27 May 2016 at 17:49:56 UTC, Adam D. Ruppe wrote: On Friday, 27 May 2016 at 17:37:38 UTC, Andrew Edwards wrote: extern (C) class IDirectSound : IUnknown That should just be `interface IDirectSound : IUnknown` Thanks for the clarification. That actually compiles but results i

Re: Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 27 May 2016 at 20:59:56 UTC, John wrote: Additionally, remove QueryInterface, AddRef and Release from the definition of IDirectSound. Also, interfaces are already references, so the definition of LPDIRECTSOUND should be: alias LPDIRECTSOUND = IDirectSound; Note there should be no

Re: Fibers under the hood

2016-06-09 Thread Andrew Edwards via Digitalmars-d-learn
On 6/9/16 2:15 PM, Jonathan Marler wrote: On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote: On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote: I've googled and searched through the forums but haven't found too much on how fibers are implemented. How does yield return execu

webfreak001: Request assist installing workspace-d on Windows

2016-07-05 Thread Andrew Edwards via Digitalmars-d-learn
I cloned the package and ran install.bat. The result is $ dub build --build=release --config=client Performing "release" build using ldc2 for x86. experimental_allocator 2.70.0-b1: building configuration "library"... Using Visual Studio: C:\Program Files (x86)\Microsoft Visual Studio 14.0\ LIN

Re: webfreak001: Request assist installing workspace-d on Windows

2016-07-05 Thread Andrew Edwards via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 19:25:50 UTC, WebFreak001 wrote: On Tuesday, 5 July 2016 at 19:14:32 UTC, Andrew Edwards wrote: There is on --config=client for the current version of dub so I went to the location of the source for experimental_allocator and ran dub build --build=release --config=

Re: webfreak001: Request assist installing workspace-d on Windows

2016-07-05 Thread Andrew Edwards via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 19:43:02 UTC, WebFreak001 wrote: On Tuesday, 5 July 2016 at 19:34:48 UTC, Andrew Edwards wrote: It's more than that. Now, it fails because it can't find DMD. As you can see in the build.bat from DCD it is hardcoded to DMD: https://github.com/Hackerpilot/DCD/blob/ma

next!T

2014-05-25 Thread Andrew Edwards via Digitalmars-d-learn
Hello All, I wrote the following convenience functions to aid in my studies. Unfortunately, I'm using Java books (Ali I will get to yours soon enough) so the need was necessitated by the frequency of use in the examples. Would appreciate a sanity check. Is there something that I should be thi

Re: next!T

2014-05-26 Thread Andrew Edwards via Digitalmars-d-learn
On 5/25/14, 10:12 PM, Ali Çehreli wrote: On 05/25/2014 05:21 PM, Andrew Edwards wrote: Hello All, I wrote the following convenience functions to aid in my studies. Unfortunately, I'm using Java books (Ali I will get to yours soon enough) so the need was necessitated by the frequency of use in t

Re: next!T

2014-06-06 Thread Andrew Edwards via Digitalmars-d-learn
On 5/25/14, 10:12 PM, Ali Çehreli wrote: On 05/25/2014 05:21 PM, Andrew Edwards wrote: Hello All, I wrote the following convenience functions to aid in my studies. Unfortunately, I'm using Java books (Ali I will get to yours soon enough) so the need was necessitated by the frequency of use in t

Re: next!T

2014-06-06 Thread Andrew Edwards via Digitalmars-d-learn
On 6/6/14, 10:57 PM, Chris Nicholson-Sauls wrote: On Saturday, 7 June 2014 at 02:23:18 UTC, Andrew Edwards wrote: Any assistance/advice is appreciated. Thanks, Andrew I got it working here by putting an else before the second static-if. Wow. Sometimes you really cannot see the things you

Re: HeadUnshared in core.atomic

2014-06-12 Thread Andrew Edwards via Digitalmars-d-learn
On 6/12/14, 1:29 AM, Mike Franklin wrote: Hello, I was recently exposed to this template in core.atomic: private { template HeadUnshared(T) { static if( is( T U : shared(U*) ) ) alias shared(U)* HeadUnshared; else alias T HeadUnshared;

Re: one of the weirdest bugs ever - request for testing

2014-06-12 Thread Andrew Edwards via Digitalmars-d-learn
On 6/12/14, 3:20 PM, captaindet wrote: import std.stdio; import std.algorithm; import std.file;// not needed, but if imported, causing trouble, see below void main() { auto names = ["one","FOO","two","three"]; // wrong code gen(*) with -release -O -inline -noboundscheck or // with -rel

Re: Cannot alias null

2014-06-12 Thread Andrew Edwards via Digitalmars-d-learn
On 6/12/14, 4:29 PM, Ali Çehreli wrote: On 06/12/2014 01:26 PM, Tom Browder via Digitalmars-d-learn wrote: > This will not compile: > >alias blah = null; > > The dmd message are: > > di/test_hdr.d(10): Error: basic type expected, not null > di/test_hdr.d(10): Error: semicolon expecte

Re: Regarding DConf 2014

2014-06-15 Thread Andrew Edwards via Digitalmars-d-learn
On 6/15/14, 8:52 AM, Adam D. Ruppe wrote: The videos are being posted at a rate of about two per week. So far talks 1-5 are up plus Scott Meyer's talk, you can find the links in the announce group. http://forum.dlang.org/group/digitalmars.D.announce Which is great... but why not link them to th

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread Andrew Edwards via Digitalmars-d-learn
On 6/17/14, 11:34 AM, George Sapkin wrote: On Tuesday, 17 June 2014 at 04:38:24 UTC, Ali Çehreli wrote: Good news: The code compiles with 2.066 after adding 'import std.algorithm;' :) Ali Thanks, but where can I get 2.066? It seems it's not going to be branched until June 30th. Is there any

Re: how can I ensure that a template instantiation is unique?

2014-06-18 Thread Andrew Edwards via Digitalmars-d-learn
On 6/19/14, 1:48 AM, Vlad Levenfeld wrote: I'm instantiating a couple of template structs that conflict with each other. I'd like them to be unique types, automatically. So I tried this: template Foo (string unique_id = __FILE__~__LINE__.to!string) {...} but it didn't work. When I use this for

Taking from infinite forward ranges

2014-08-04 Thread Andrew Edwards via Digitalmars-d-learn
Is there a way to take a bounded rage from a infinite forward range? Given the Fibonacci sequence: auto fib = recurrence!("a[n-1] + a[n-2]")(1, 1); I can take the first n elements: take(fib, 10); But say I want all positive elements below 5 in value (there are eight such

Re: Taking from infinite forward ranges

2014-08-04 Thread Andrew Edwards via Digitalmars-d-learn
On 8/5/14, 10:28 AM, Brad Anderson wrote: On Tuesday, 5 August 2014 at 01:23:19 UTC, Andrew Edwards wrote: Is there a way to take a bounded rage from a infinite forward range? I'd use std.algorithm.until: Precisely what I was looking for. Thanks.

request assistance resolving curl related linker error

2014-08-18 Thread Andrew Edwards via Digitalmars-d-learn
import std.net.curl; void main(){} // Output: Undefined symbols for architecture x86_64: "_curl_easy_cleanup", referenced from: _D3std3net4curl4Curl8shutdownMFZv in libphobos2.a(curl_3063_37c.o) "_curl_easy_setopt", referenced from: _D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOp

Re: request assistance resolving curl related linker error

2014-08-18 Thread Andrew Edwards via Digitalmars-d-learn
On 8/19/14, 1:09 AM, Martin Nowak wrote: On Monday, 18 August 2014 at 14:24:54 UTC, Andrew Edwards wrote: import std.net.curl; void main(){} // Output: Undefined symbols for architecture x86_64: "_curl_easy_cleanup", referenced from: The problem here is that std.net.curl is based on libcu

Re: request assistance resolving curl related linker error

2014-08-18 Thread Andrew Edwards via Digitalmars-d-learn
On Tuesday, 19 August 2014 at 02:24:48 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 19 Aug 2014 09:56:30 +0900 Andrew Edwards via Digitalmars-d-learn wrote: > Add '-L-lcurl' to your dmd invocation to do this. Okay, got it. Thank you much. or you can add pragma(lib, &quo

Fibers

2014-09-17 Thread Andrew Edwards via Digitalmars-d-learn
The script below is borrowed form a unit test in core.thread and modified slightly. If fails with "segmentation fault: 11" but I'm not sure why. Basically what I'm trying to do is to transact on every file in give directory at the same time exact time. In this exam, I'm removing the file/dir

Re: Fibers

2014-09-17 Thread Andrew Edwards via Digitalmars-d-learn
On 9/17/14, 9:43 PM, Kagamin wrote: fibs ~= new TestFiber(entry); should just work without accounting for number of items Kagamin/Flamencofantasy, thank you very much.

Recursive-descent parsing

2016-12-24 Thread Andrew Edwards via Digitalmars-d-learn
The authors of "The Art of Java" present, as a first coding example, a recursive-descent parser to demonstrate Java's ability to facilitate low level programming commonly performed in C and C++. I took the opportunity to port the code to D. By doing this, I now have an understanding of how a

warning: pointer not aligned at address

2017-04-11 Thread Andrew Edwards via Digitalmars-d-learn
When compiled with any dmd compiler from 2.069.0 through present (2.074.0), https://rosettacode.org/wiki/100_doors#D produces the following linker warning: ld: warning: pointer not aligned at address 0x10004FCEB (_D51TypeInfo_S3std5range13__T4iotaTiTmZ4iotaFimZ6Result6__initZ + 24 from doors1

Re: warning: pointer not aligned at address

2017-04-11 Thread Andrew Edwards via Digitalmars-d-learn
Conveniently the site is down immediately after I posted that so here is the code to which I was referring: import std.stdio, std.algorithm, std.range; enum DoorState : bool { closed, open } alias Doors = DoorState[]; Doors flipUnoptimized(Doors doors) pure nothrow { doors[] = DoorState.cl

Re: warning: pointer not aligned at address

2017-04-12 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 03:18:32 UTC, Matt Whisenhunt wrote: ld: warning: pointer not aligned at address 0x100050C7D Are you running macOS and recently installed an update to Xcode? I ran into this today as well. Looks like other have too: https://issues.dlang.org/show_bug.cgi?id=17289

Re: Problem with using readln.

2017-04-29 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:20:20 UTC, JV wrote: On Sunday, 30 April 2017 at 03:18:04 UTC, Adam D. Ruppe wrote: On Sunday, 30 April 2017 at 03:10:25 UTC, JV wrote: btw i forgot to add () at readln while editing the post That's not necessary, it doesn't change anything. But readln without

Access specifiers and visibility

2017-05-09 Thread Andrew Edwards via Digitalmars-d-learn
Attempting to update a git repo to current D, I encounter the following deprecation messages: src/glwtf/signals.d-mixin-256(256,2): Deprecation: glwtf.input.BaseGLFWEventHandler._on_key_down is not visible from module glwtf.signals src/glwtf/signals.d-mixin-256(256,2): Deprecation: glwtf.inpu

Re: Access specifiers and visibility

2017-05-10 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 13:13:46 UTC, Jesse Phillips wrote: On Wednesday, 10 May 2017 at 01:42:47 UTC, Andrew Edwards wrote: Attempting to update a git repo to current D, I encounter the following deprecation messages: src/glwtf/signals.d-mixin-256(256,2): Deprecation: glwtf.input.BaseGL

Re: Access specifiers and visibility

2017-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 11 May 2017 at 04:35:22 UTC, Jesse Phillips wrote: On Wednesday, 10 May 2017 at 13:29:40 UTC, Andrew Edwards wrote: On Wednesday, 10 May 2017 at 13:13:46 UTC, Jesse Phillips wrote: On Wednesday, 10 May 2017 at 01:42:47 UTC, Andrew Edwards wrote: Attempting to update a git repo to c

  1   2   >