Re: how to access struct member using [] operator?

2016-09-25 Thread grampus via Digitalmars-d-learn
On Sunday, 25 September 2016 at 09:01:44 UTC, Namespace wrote: On Sunday, 25 September 2016 at 04:54:31 UTC, grampus wrote: Dear all For example, I have a struct struct point{int x;int y} point a; Is there an easy way to access x and y by using a["x"] and a["y"] I guess I need to overload [

Re: how to access struct member using [] operator?

2016-09-25 Thread grampus via Digitalmars-d-learn
On Sunday, 25 September 2016 at 10:44:38 UTC, pineapple wrote: On Sunday, 25 September 2016 at 04:54:31 UTC, grampus wrote: Dear all For example, I have a struct struct point{int x;int y} point a; Is there an easy way to access x and y by using a["x"] and a["y"] I guess I need to overload [

how to access struct member using [] operator?

2016-09-24 Thread grampus via Digitalmars-d-learn
Dear all For example, I have a struct struct point{int x;int y} point a; Is there an easy way to access x and y by using a["x"] and a["y"] I guess I need to overload [], but can't figure out how. Someone can help? Thank you very much

Re: How to use std. packages in so files written in dlang

2016-08-11 Thread grampus via Digitalmars-d-learn
On Friday, 12 August 2016 at 02:31:29 UTC, ketmar wrote: On Friday, 12 August 2016 at 01:36:34 UTC, grampus wrote: [...] then you have to check if runtime is initialized at the start of each function that can be called from C side. like this: [...] Understand, I will be careful here. Than

Re: How to use std. packages in so files written in dlang

2016-08-11 Thread grampus via Digitalmars-d-learn
On Friday, 12 August 2016 at 01:45:29 UTC, Mike Parker wrote: On Friday, 12 August 2016 at 01:36:34 UTC, grampus wrote: On Friday, 12 August 2016 at 01:09:47 UTC, ketmar wrote: On Friday, 12 August 2016 at 00:57:42 UTC, grampus wrote: it's 'cause you didn't initialized druntime. you have to us

Re: How to use std. packages in so files written in dlang

2016-08-11 Thread grampus via Digitalmars-d-learn
On Friday, 12 August 2016 at 01:09:47 UTC, ketmar wrote: On Friday, 12 August 2016 at 00:57:42 UTC, grampus wrote: it's 'cause you didn't initialized druntime. you have to use dlsym to get "rt_init" function and call it right after loading your .so, but before calling any other API from it.

How to use std. packages in so files written in dlang

2016-08-11 Thread grampus via Digitalmars-d-learn
Hi,erveryone I am trying to use dLang to make so file for existing c/c++ project. I followed the examples on https://dlang.org/dll-linux.html, which works well. but when I replaced import core.stdc.stdio; with import std.stdio; to use writefln() instead of printf(), then things changed. compi