digitalmars.D.learn - dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern
- Tal (19/19) Dec 25 2011 Linking the following two files gives me a link-error:
- Andrej Mitrovic (4/4) Dec 25 2011 You can't prototype D functions like that, they belong to a module.
- Tal (2/2) Dec 25 2011 I want to save the hInstance of WinMain so I would be able to use it lat...
- Joshua Reusch (2/4) Dec 25 2011 just define a public variable in the global scope.
- Tal (2/2) Dec 25 2011 I'm quite new to this language, could you please provide a short snippet...
- Joshua Reusch (13/15) Dec 25 2011 --- a.d:
- Jakob Ovrum (3/4) Dec 25 2011 It's important to note that public is the default access level
- Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern (1/1) Dec 27 2011 Thanks, this is it!
- Joshua Reusch (3/5) Dec 25 2011 If you don't know: You can also get the HINSTANCE with
Linking the following two files gives me a link-error: a.d: import std.stdio; extern (D) string test (); void main() { writeln(test()); readln(); } ____________________________________ b.d: string test () { return "hello"; } ____________________________________ the error I get is: Error 42: Symbol Undefined _D1a4testFZAya` ---errorlevel 1 What is wrong ?
Dec 25 2011
You can't prototype D functions like that, they belong to a module. test is built as _D1b4testFZAya, not _D1a4testFZAya (notice the module names, a and b after _D1). What exactly are you trying to do? DLLs?
Dec 25 2011
I want to save the hInstance of WinMain so I would be able to use it later in some other module. So how do I accomplish that ?
Dec 25 2011
Am 25.12.2011 22:37, schrieb Tal:I want to save the hInstance of WinMain so I would be able to use it later in some other module. So how do I accomplish that ?just define a public variable in the global scope.
Dec 25 2011
I'm quite new to this language, could you please provide a short snippet of code to clarify ?
Dec 25 2011
Am 25.12.2011 23:26, schrieb Tal:I'm quite new to this language, could you please provide a short snippet of code to clarify ?--- a.d: import std.stdio; import b; void main() { writeln("some_var from Module b: \"", b.some_var, "\""); } --- b.d: public string some_var = "Hello, world!"; //you can also use static module constructors to set your vars static this() { some_var ~= " -- How are you?"; }
Dec 25 2011
On Sunday, 25 December 2011 at 22:46:33 UTC, Joshua Reusch wrote:public string some_var = "Hello, world!";It's important to note that public is the default access level here.
Dec 25 2011
Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern <publictal gmail.com> writes:
Thanks, this is it!
Dec 27 2011
Am 25.12.2011 22:37, schrieb Tal:I want to save the hInstance of WinMain so I would be able to use it later in some other module. So how do I accomplish that ?If you don't know: You can also get the HINSTANCE with GetModuleHandle(NULL);
Dec 25 2011