digitalmars.D - Error: class myClass.myClass() is used as a type
- rsk82 (13/13) Jan 27 2013 this is my module:
- Dicebot (3/16) Jan 27 2013 new MyClass.MyClass(), I suppose. Despite import is public,
- rsk82 (3/5) Jan 27 2013 Nope. I changed module name to myClass_mod, now got this:
- Daniel Kozak (10/23) Jan 27 2013 class myClass () {
- rsk82 (13/18) Jan 27 2013 Thanks, that killed the original error. Now the linker says:
- jerro (4/24) Jan 27 2013 You need to put myClass_mod.d (or what ever the file name is) on
- Andrei Alexandrescu (5/8) Jan 27 2013 BTW I just sent a pull request that makes rdmd faster for large projects...
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (13/24) Jan 27 2013 Yeah... Those empty parentheses were making myClass a class template,
- Namespace (1/1) Jan 27 2013 All of your topics shouldn't be here. Post in D.learn instead.
- F i L (18/19) Jan 28 2013 module myClass (myclass.d);
- F i L (3/6) Jan 28 2013 Whoops, forgot to remove the '()' after 'myClass'. As others have
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 ?
Jan 27 2013
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.
Jan 27 2013
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
Jan 27 2013
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() { } }
Jan 27 2013
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.
Jan 27 2013
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: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.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.
Jan 27 2013
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
Jan 27 2013
On 01/27/2013 12:13 PM, Daniel Kozak wrote:On Sunday, 27 January 2013 at 19:55:07 UTC, rsk82 wrote: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; } AliWhat's wrong here ?class myClass () { this() { } }; should be class myClass { this() { } }
Jan 27 2013
All of your topics shouldn't be here. Post in D.learn instead.
Jan 27 2013
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()
Jan 28 2013
F i L wrote:class myClass() { this() { ... } }Whoops, forgot to remove the '()' after 'myClass'. As others have pointed out, that will make 'myClass' a template-class.
Jan 28 2013