Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 27, 2013 Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
this is my module: module myClass; class myClass () { this() { } }; and main app: import myClass; int main() { myClass my_instance = new myClass(); return 0; } What's wrong here ? |
January 27, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to rsk82 | On Sunday, 27 January 2013 at 19:55:07 UTC, rsk82 wrote:
> this is my module:
>
> module myClass;
>
> class myClass () {
> this() {
>
> }
> };
>
> and main app:
>
> import myClass;
>
> int main() {
> myClass my_instance = new myClass();
> return 0;
> }
>
> What's wrong here ?
new MyClass.MyClass(), I suppose. Despite import is public, module symbol has higher priority in name resolution.
|
January 27, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Sunday, 27 January 2013 at 20:04:17 UTC, Dicebot wrote:
> new MyClass.MyClass(), I suppose. Despite import is public, module symbol has higher priority in name resolution.
Nope. I changed module name to myClass_mod, now got this:
Error: class myClass_mod.myClass() is used as a type
|
January 27, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to rsk82 | On Sunday, 27 January 2013 at 19:55:07 UTC, rsk82 wrote:
> this is my module:
>
> module myClass;
>
> class myClass () {
> this() {
>
> }
> };
>
> and main app:
>
> import myClass;
>
> int main() {
> myClass my_instance = new myClass();
> return 0;
> }
>
> What's wrong here ?
class myClass () {
this() {
}
};
should be
class myClass {
this() {
}
}
|
January 27, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to rsk82 | All of your topics shouldn't be here. Post in D.learn instead. |
January 27, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | On Sunday, 27 January 2013 at 20:13:05 UTC, Daniel Kozak wrote: > should be > > class myClass { > this() { > > } > } Thanks, that killed the original error. Now the linker says: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html t3.obj(t3) Error 42: Symbol Undefined _D11myClass_mod7myClass6__ctorMFZC11myClass_mod7myClass t3.obj(t3) Error 42: Symbol Undefined _D11myClass_mod7myClass7__ClassZ --- errorlevel 2 @Namespace: ok, I will post my new topics there, but I like to end with this issue and not create another topic for that. |
January 27, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to rsk82 | On Sunday, 27 January 2013 at 20:24:38 UTC, rsk82 wrote:
> On Sunday, 27 January 2013 at 20:13:05 UTC, Daniel Kozak wrote:
>> should be
>>
>> class myClass {
>> this() {
>>
>> }
>> }
>
> Thanks, that killed the original error. Now the linker says:
>
> OPTLINK (R) for Win32 Release 8.00.12
> Copyright (C) Digital Mars 1989-2010 All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> t3.obj(t3)
> Error 42: Symbol Undefined _D11myClass_mod7myClass6__ctorMFZC11myClass_mod7myClass
> t3.obj(t3)
> Error 42: Symbol Undefined _D11myClass_mod7myClass7__ClassZ
> --- errorlevel 2
>
>
> @Namespace: ok, I will post my new topics there, but I like to end with this issue and not create another topic for that.
You need to put myClass_mod.d (or what ever the file name is) on the command line. You could also use rdmd, which will find all the imported files automatically.
|
January 28, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to jerro | On 1/27/13 3:29 PM, jerro wrote: > You need to put myClass_mod.d (or what ever the file name is) on the > command line. You could also use rdmd, which will find all the imported > files automatically. BTW I just sent a pull request that makes rdmd faster for large projects by reducing the number of stat calls: https://github.com/D-Programming-Language/tools/pull/41 Andrei |
January 28, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | On 01/27/2013 12:13 PM, Daniel Kozak wrote: > On Sunday, 27 January 2013 at 19:55:07 UTC, rsk82 wrote: >> What's wrong here ? > > class myClass () { > this() { > > } > }; > > should be > > class myClass { > this() { > > } > } Yeah... Those empty parentheses were making myClass a class template, not a class. Apparently the syntax (or the compiler) allows template definitions without template parameters, which can still be instantiated: class myClass () { this() { } } int main() { myClass!() my_instance = new myClass!(); return 0; } Ali |
January 29, 2013 Re: Error: class myClass.myClass() is used as a type | ||||
---|---|---|---|---|
| ||||
Posted in reply to rsk82 | rsk82 wrote:
> What's wrong here ?
module myClass (myclass.d);
class myClass() {
this() { ... }
}
and main app (main.d):
import myclass;
void main() {
myClass my_instance = new myClass();
}
then compile with:
$ dmd main.d myclass.d
or:
$ dmd main myclass
or:
$ rdmd main
ps. Module names should be lowercase (see docs), and you can safely use 'void' for main()
|
Copyright © 1999-2021 by the D Language Foundation