www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - TypeInfo class conflict

reply Eric Desbiens <olace99 hormail.com> writes:
Hi,

	I need to create a class name TypeInfo in my D project. Unfortunately, 
this class exist in the phobos library (define in objectd.d) and I 
cannot compile it because it gives an error of multiple definition.

	How can I declare the TypeInfo class in my module so it will not 
conflict with the one in object.d ?

I cannot change the name of the class.

Thanks!
Eric
May 25 2004
parent reply Stephan Wienczny <wienczny web.de> writes:
You can call your class TypeInfo. When referring to it you will have to 
use <YourModuleName>.TypeInfo for your class.
Why can't you change the name of your class?

Eric Desbiens wrote:
 Hi,
 
     I need to create a class name TypeInfo in my D project. 
 Unfortunately, this class exist in the phobos library (define in 
 objectd.d) and I cannot compile it because it gives an error of multiple 
 definition.
 
     How can I declare the TypeInfo class in my module so it will not 
 conflict with the one in object.d ?
 
 I cannot change the name of the class.
 
 Thanks!
 Eric
May 25 2004
parent reply Eric Desbiens <olace99 hormail.com> writes:
I cannot rename the class because I am trying to implement XML DOM Level 
3 specification to learn D with a real world example. The spec need to 
have a class called TypeInfo, if I rename the class it break the spec.

I know that I could access it with using <YourModuleName>.TypeInfo, 
that's fine. But my code will not compile at all if I put a class name 
TypeInfo in it. You can try it, just put class TypeInfo{} in a .d file 
and try compilling. It gives me this error message :

libphobos.a(object.o)(.rodata+0xb8): multiple definition of 
`_init_8TypeInfo'
bug.o(.rodata+0x0): first defined here
libphobos.a(object.o)(.data+0x78): multiple definition of `_Class_8TypeInfo'
bug.o(.data+0x0): first defined here
libphobos.a(object.o)(.rodata+0xcc): multiple definition of 
`_vtbl_8TypeInfo'
bug.o(.rodata+0x14): first defined here
collect2: ld returned 1 exit status
--- errorlevel 256

I am using dmd 0.90 for Linux

Thanks!
Eric


Stephan Wienczny wrote:
 You can call your class TypeInfo. When referring to it you will have to 
 use <YourModuleName>.TypeInfo for your class.
 Why can't you change the name of your class?
 
 Eric Desbiens wrote:
 
 Hi,

     I need to create a class name TypeInfo in my D project. 
 Unfortunately, this class exist in the phobos library (define in 
 objectd.d) and I cannot compile it because it gives an error of 
 multiple definition.

     How can I declare the TypeInfo class in my module so it will not 
 conflict with the one in object.d ?

 I cannot change the name of the class.

 Thanks!
 Eric
May 25 2004
next sibling parent reply Stephan Wienczny <wienczny web.de> writes:
I tested it. Maybe I should not have used -c ...

Eric Desbiens wrote:
 I cannot rename the class because I am trying to implement XML DOM Level 
 3 specification to learn D with a real world example. The spec need to 
 have a class called TypeInfo, if I rename the class it break the spec.
 
 I know that I could access it with using <YourModuleName>.TypeInfo, 
 that's fine. But my code will not compile at all if I put a class name 
 TypeInfo in it. You can try it, just put class TypeInfo{} in a .d file 
 and try compilling. It gives me this error message :
 
 libphobos.a(object.o)(.rodata+0xb8): multiple definition of 
 `_init_8TypeInfo'
 bug.o(.rodata+0x0): first defined here
 libphobos.a(object.o)(.data+0x78): multiple definition of 
 `_Class_8TypeInfo'
 bug.o(.data+0x0): first defined here
 libphobos.a(object.o)(.rodata+0xcc): multiple definition of 
 `_vtbl_8TypeInfo'
 bug.o(.rodata+0x14): first defined here
 collect2: ld returned 1 exit status
 --- errorlevel 256
 
 I am using dmd 0.90 for Linux
 
 Thanks!
 Eric
 
 
 Stephan Wienczny wrote:
 
 You can call your class TypeInfo. When referring to it you will have 
 to use <YourModuleName>.TypeInfo for your class.
 Why can't you change the name of your class?

 Eric Desbiens wrote:

 Hi,

     I need to create a class name TypeInfo in my D project. 
 Unfortunately, this class exist in the phobos library (define in 
 objectd.d) and I cannot compile it because it gives an error of 
 multiple definition.

     How can I declare the TypeInfo class in my module so it will not 
 conflict with the one in object.d ?

 I cannot change the name of the class.

 Thanks!
 Eric
May 25 2004
parent Eric Desbiens <olace99 hormail.com> writes:
You are right it compile. It is when it try to do the linking that it choke.

Any idea why ?

Stephan Wienczny wrote:
 I tested it. Maybe I should not have used -c ...
 
 Eric Desbiens wrote:
 
 I cannot rename the class because I am trying to implement XML DOM 
 Level 3 specification to learn D with a real world example. The spec 
 need to have a class called TypeInfo, if I rename the class it break 
 the spec.

 I know that I could access it with using <YourModuleName>.TypeInfo, 
 that's fine. But my code will not compile at all if I put a class name 
 TypeInfo in it. You can try it, just put class TypeInfo{} in a .d file 
 and try compilling. It gives me this error message :

 libphobos.a(object.o)(.rodata+0xb8): multiple definition of 
 `_init_8TypeInfo'
 bug.o(.rodata+0x0): first defined here
 libphobos.a(object.o)(.data+0x78): multiple definition of 
 `_Class_8TypeInfo'
 bug.o(.data+0x0): first defined here
 libphobos.a(object.o)(.rodata+0xcc): multiple definition of 
 `_vtbl_8TypeInfo'
 bug.o(.rodata+0x14): first defined here
 collect2: ld returned 1 exit status
 --- errorlevel 256

 I am using dmd 0.90 for Linux

 Thanks!
 Eric


 Stephan Wienczny wrote:

 You can call your class TypeInfo. When referring to it you will have 
 to use <YourModuleName>.TypeInfo for your class.
 Why can't you change the name of your class?

 Eric Desbiens wrote:

 Hi,

     I need to create a class name TypeInfo in my D project. 
 Unfortunately, this class exist in the phobos library (define in 
 objectd.d) and I cannot compile it because it gives an error of 
 multiple definition.

     How can I declare the TypeInfo class in my module so it will not 
 conflict with the one in object.d ?

 I cannot change the name of the class.

 Thanks!
 Eric
May 25 2004
prev sibling next sibling parent "Walter" <newshound digitalmars.com> writes:
I intend to revamp the TypeInfo stuff, the way it is now is too much of a
kludge. Unfortunately, you're going to need to change the name of your
TypeInfo to get it to work.
May 25 2004
prev sibling parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
"Eric Desbiens" <olace99 hormail.com> wrote in message
news:c8vv1b$1j4o$1 digitaldaemon.com...
 I cannot rename the class because I am trying to implement XML DOM Level
 3 specification to learn D with a real world example. The spec need to
 have a class called TypeInfo, if I rename the class it break the spec.
To quote from http://www.w3.org/TR/DOM-Level-3-Core/introduction.html#ID-Conformance "DOM implementations in languages other than Java or ECMAScript may choose bindings that are appropriate and natural for their language and run time environment. For example, some systems may need to create a Document3 class which inherits from a Document class and contains the new methods and attributes. " I suggest using DOMTypeInfo instead of TypeInfo.
May 25 2004
parent Eric Desbiens <olace99 hormail.com> writes:
Thanks everybody!

I'll use DOMTypeInfo as suggested for now until Walter rework the 
TypeInfo stuff and hopefully I will be able to use TypeInfo class name 
later. It would make more sense to use the same name and specifying the 
module like dom.TypeInfo than using a different name from the spec. But 
for now it will do.

Have a nice day everybody!
Eric

Ben Hinkle wrote:
 "Eric Desbiens" <olace99 hormail.com> wrote in message
 news:c8vv1b$1j4o$1 digitaldaemon.com...
 
I cannot rename the class because I am trying to implement XML DOM Level
3 specification to learn D with a real world example. The spec need to
have a class called TypeInfo, if I rename the class it break the spec.
To quote from http://www.w3.org/TR/DOM-Level-3-Core/introduction.html#ID-Conformance "DOM implementations in languages other than Java or ECMAScript may choose bindings that are appropriate and natural for their language and run time environment. For example, some systems may need to create a Document3 class which inherits from a Document class and contains the new methods and attributes. " I suggest using DOMTypeInfo instead of TypeInfo.
May 25 2004