www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - lambda alias import

reply JN <666total wp.pl> writes:
stuff.d:

alias doStuff = () {};

main.d:

import stuff;

void main()
{
   doStuff();
}


DMD throws compile error:

  Error 42: Symbol Undefined __D5stuff9__lambda3FNaNbNiNfZv

Is this expected behavior? It tripped me while trying to use 
DerelictVulkan :(
Jan 17 2020
parent reply Petar Kirov [ZombineDev] <petar.p.kirov gmail.com> writes:
On Friday, 17 January 2020 at 21:40:05 UTC, JN wrote:
 stuff.d:

 alias doStuff = () {};

 main.d:

 import stuff;

 void main()
 {
   doStuff();
 }


 DMD throws compile error:

  Error 42: Symbol Undefined __D5stuff9__lambda3FNaNbNiNfZv

 Is this expected behavior? It tripped me while trying to use 
 DerelictVulkan :(
I think the problem comes from the way you compile and link your code. I you compile both modules together like this it should work out: dmd -ofresult main.d stuff.d (I'm on the phone, so I can't verify if it works atm)
Jan 17 2020
next sibling parent Petar Kirov [ZombineDev] <petar.p.kirov gmail.com> writes:
On Friday, 17 January 2020 at 23:04:57 UTC, Petar Kirov 
[ZombineDev] wrote:
 [..]
*If* you compile both modules ..
 [..]
Jan 17 2020
prev sibling parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 1/17/20 3:04 PM, Petar Kirov [ZombineDev] wrote:> On Friday, 17 
January 2020 at 21:40:05 UTC, JN wrote:

 I think the problem comes from the way you compile and link your code. I
 you compile both modules together like this it should work out:

 dmd -ofresult main.d stuff.d
If that's the solution, some people may find a relatively less known dmd command line switch useful: -i: -i[=<pattern>] include imported modules in the compilation Ali
Jan 17 2020
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Fri, Jan 17, 2020 at 04:12:18PM -0800, Ali Çehreli via Digitalmars-d-learn
wrote:
 On 1/17/20 3:04 PM, Petar Kirov [ZombineDev] wrote:> On Friday, 17 January
 2020 at 21:40:05 UTC, JN wrote:
 
 I think the problem comes from the way you compile and link your
 code. I you compile both modules together like this it should work
 out:

 dmd -ofresult main.d stuff.d
If that's the solution, some people may find a relatively less known dmd command line switch useful: -i: -i[=<pattern>] include imported modules in the compilation
[...] Yeah, -i has been a super-convenient thing to use. For unittesting individual modules, etc., I can just `dmd -i -unittest -main -run module.d` and it Just Works(tm). It's awesome. Highly recommended. T -- A programming language should be a toolbox for the programmer to draw upon, not a minefield of dangerous explosives that you have to very carefully avoid touching in the wrong way.
Jan 17 2020