Re: Implicit conversion from array of class to array of interface
casting an array of class references to an array of interface references (or vice versa) will not work at runtime. Your program will crash. This is because if the invisible pointer correction that is done if you cast a single class ref to an interface ref. C c = new C; I i = c; writefln( "c=%d i=%i", cast(uint)cast(void*)c, cast(uint)cast(void*)i); This shows, the numeric values are not equal. At the assignment were an imlicit cast is taking place, dmd inserts a pointer adjustement. If you cast an array, nothing physically is done to the array content. In fact you need to run a loop over the array and cast each member on it own.
Re: Win32 to D
nomad schrieb: > I would like to use the following Win32 function in D: > > GpStatus WINGDIPAPI GdipEnumerateMetafileSrcRectDestPointI( > GpGraphics * graphics, > GDIPCONST GpMetafile * metafile, > GDIPCONST Point & destPoint, > GDIPCONST Rect & srcRect, > Unit srcUnit, > EnumerateMetafileProc callback, > VOID * callbackData, > GDIPCONST GpImageAttributes * imageAttributes > ); > > what is the proper way to do so? > > FYI, there is GDI+ in DWT, see dwt-win\dwt\internal\gdip\
Re: 2 File IO Questions (Phobos)
Zane schrieb: > Doh! I still need help with number 2, but for number 1, all I needed > was to use 'writeString' instead of 'write'. Like I said, still > getting used to Phobos. Like I said, I still need help on the > destructor question (#2). > > Thanks, Zane desctructors are called in not defined order. The GC puts your class instance 'sw' and the File instance 'sw.file' onto the list for destruction. So the 'sw.file' might be destructed before 'sw' is. Deferencing sw.file from withing sw.~this then fails. A general rule: in a dtor, never dereference member variables. You have to rely on the File dtor, to close himself if still open.
Re: Modules/packages and cryptic errors
al schrieb: > Frank Benoit Wrote: > >> al schrieb: >>> module bar is in multiple defined >> This often indicates a modules file name and the identifier in the >> "module" statement are unequal (case sensitivity) > > I have all files and imports lowercase. I have class names following > filenames capitalized, but that shouldn't matter, should it? > > > When I run: > > dmd foo/bar.d > > is that assuming module foo.bar or bar? If that's the latter, it might > explain why I'm getting an error (import finds this file under foo.bar), but > how should I compile files then? > > if 'foo' shall be package, in bar.d there should be "module foo.bar;". If imported from somewhere else, it should be "import foo.bar;". Class/Type names should not matter.
Re: Modules/packages and cryptic errors
al schrieb: > module bar is in multiple defined This often indicates a modules file name and the identifier in the "module" statement are unequal (case sensitivity)
Re: some strange behavior
//o schrieb: > Writing a small opengl text printer (vertex based) I have found that the next > lines are "illegal" to dmd (2.031): > > invariant float[][][] CHARS =[ > [//A > [0,0], > [1/2f,2], > [1,0], > [3/4f,1], > [1/4f,1] > ] > ]; > > dmd complains (compiling with dmd -c bug.d): > bug.d(9): Error: cannot implicitly convert expression ([0.5F,2F]) of type > float[2u] to int[] > bug.d(9): Error: cannot implicitly convert expression ([0.75F,1F]) of type > float[2u] to int[] > bug.d(9): Error: cannot implicitly convert expression ([0.25F,1F]) of type > float[2u] to int[] > > is this a bug? > > thanks. > -- > if this mesage is repeated there's a problem with my browser The type of the first element makes the type of the array literal. "0" is of type int, try 0f. invariant float[][][] CHARS =[ [//A [0f,0], [1/2f,2], [1,0], [3/4f,1], [1/4f,1] ] ];
Re: any html parser with d binding
Robert Fraser schrieb: > reimi gibbons wrote: >> 2) how reliable is bcd to create binding for c libraries? > > C? Very reliable (unless it uses weird compiler directives). C++ is a > bit trickier. Last time I used BCD, it had no support for bitfields and generated struct definition that do not match in size with their original. So in general when doing C bindings, i do a check of struct sizes by writing a C and a D program outputting the sizes and compare the outputs with kdiff3 for manual tweaking the structs in D.
Re: euro sign
Sivo Schilling schrieb: > nobody Wrote: > >> Hello, >> >> import std.stdio; >> >> void main() { >> wchar w_sonderzeichen= '\u20ac';// Euro Zeichen >> writef("w_sonderzeichen = %s ",w_sonderzeichen) ; >> } >> >> ca...@capri-desktop:~/dd$ dmd utf_test.d >> /home/capri/dd/dmd/src/phobos/std/stdio.d(823): Error: undefined identifier >> backend >> /home/capri/dd/dmd/src/phobos/std/stdio.d(823): Error: function >> std.stdio.fputc_unlocked (int, _iobuf*) does not match parameter types >> (wchar,int) >> /home/capri/dd/dmd/src/phobos/std/stdio.d(823): Error: cannot implicitly >> convert expression (backend) of type int to _iobuf* >> /home/capri/dd/dmd/src/phobos/std/stdio.d(830): Error: undefined identifier >> backend >> /home/capri/dd/dmd/src/phobos/std/stdio.d(830): Error: function >> std.stdio.fputc_unlocked (int, _iobuf*) does not match parameter types >> (char,int) >> /home/capri/dd/dmd/src/phobos/std/stdio.d(830): Error: cannot implicitly >> convert expression (backend) of type int to _iobuf* >> /home/capri/dd/dmd/src/phobos/std/stdio.d(835): Error: undefined identifier >> backend >> /home/capri/dd/dmd/src/phobos/std/stdio.d(835): Error: function >> std.stdio.fputwc_unlocked (dchar, _iobuf*) does not match parameter types >> (wchar,int) >> /home/capri/dd/dmd/src/phobos/std/stdio.d(835): Error: cannot implicitly >> convert expression (backend) of type int to _iobuf* >> /home/capri/dd/dmd/src/phobos/std/stdio.d(1982): Error: template instance >> std.stdio.File.LockingTextWriter.put!(wchar) error instantiating >> >> DMD 2.029 under linux >> > > Hi > > the error messages are the same on Windows XP. The problem > seems to be the type of 'w_sonderzeichen'. > If you change the type from wchar to dchar then dmd is happy > and at least on linux you see the Euro sign (on Windows console > output is not very useful). > > Chears, > Sivo. > > --- > import std.stdio; > > void main() > { > dchar w_sonderzeichen = '\u20ac';// Euro Zeichen > writefln("w_sonderzeichen = %s ", w_sonderzeichen) ; > } > --- > > Output: > w_sonderzeichen = € > The windows console is by default adjusted to your local codepage. It can be set to be utf8 with the shell command "chcp 65001" or your program can do that with "SetConsoleCP( CP_UTF8 );" In Tango programs this is done by default, afaik. The compile errors you see seems like a implementation bug in phobos to me. You can also use char[] instead of dchar, char[] w_sonderzeichen = "\u20ac";
Re: What does this linker messages try to tell me?
Christopher Wright schrieb: > There are two definitions for AstractObservableList.add(Object) in > org.eclipse.core.databinding.observable.list.AstractObservableList. > > Most of the rest of the problems are the same issue, just for different > functions. > > I would guess that you built one version, updated, and built again > without first cleaning, and somehow got duplicate object files somewhere. > > There are also some undefined symbols. If you haven't modified your dwt > working copy, I'd delete it and install from scratch. Thanks, that helped a lot.
What does this linker messages try to tell me?
OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved. C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(AbstractObservableList) Offset F0567H Record Type 00C3 Error 1: Previous Definition Different : _D3org7eclipse4core11databinding10observable4list22AbstractObservabl eList22AbstractObservableList3addMFC6ObjectZb C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(AbstractObservableList) Offset F070DH Record Type 00C3 Error 1: Previous Definition Different : _D3org7eclipse4core11databinding10observable4list22AbstractObservabl eList22AbstractObservableList6removeMFC6ObjectZb C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(PrintWriter) Offset 0ABF6H Record Type 00C3 Error 1: Previous Definition Different : _D4java2io11PrintWriter11PrintWriter5printMFAaZv C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(PrintWriter) Offset 0AEA6H Record Type 00C3 Error 1: Previous Definition Different : _D4java2io11PrintWriter11PrintWriter7printlnMFAaZv C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(PrintWriter) Offset 0AFF3H Record Type 00C3 Error 1: Previous Definition Different : _D4java2io11PrintWriter11PrintWriter5writeMFAaZv C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(PrintWriter) Offset 0B038H Record Type 00C3 Error 1: Previous Definition Different : _D4java2io11PrintWriter11PrintWriter5writeMFAaiiZv C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(PrintStream) Offset 0827CH Record Type 00C3 Error 1: Previous Definition Different : _D4java2io11PrintStream11PrintStream5printMFAaZv C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(PrintStream) Offset 0852CH Record Type 00C3 Error 1: Previous Definition Different : _D4java2io11PrintStream11PrintStream7printlnMFAaZv C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(NumberToFloatConverter) Error 42: Symbol Undefined _D3com3ibm3icu4text12NumberFormat12__ModuleInfoZ C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(UpdateStrategy) Error 42: Symbol Undefined _D3com3ibm3icu4text12NumberFormat12NumberFormat18getIntegerInstanceFZC3com3ibm3icu 4text12NumberFormat12NumberFormat C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(UpdateStrategy) Error 42: Symbol Undefined _D3com3ibm3icu4text12NumberFormat12NumberFormat17getNumberInstanceFZC3com3ibm3icu4 text12NumberFormat12NumberFormat C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(BindingMessages) Error 42: Symbol Undefined _D3com3ibm3icu4text13MessageFormat13MessageFormat6formatFAaAC6ObjectZAa C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(BindingMessages) Error 42: Symbol Undefined _D3com3ibm3icu4text13MessageFormat12__ModuleInfoZ C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(DateConversionSupport) Error 42: Symbol Undefined _D3com3ibm3icu4text10DateFormat10DateFormat15getTimeInstanceFiZC3com3ibm3icu4text1 0DateFormat10DateFormat C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(DateConversionSupport) Error 42: Symbol Undefined _D3com3ibm3icu4text10DateFormat10DateFormat19getDateTimeInstanceFiiZC3com3ibm3icu4 text10DateFormat10DateFormat C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(DateConversionSupport) Error 42: Symbol Undefined _D3com3ibm3icu4text10DateFormat10DateFormat15getDateInstanceFiZC3com3ibm3icu4text1 0DateFormat10DateFormat C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(DateConversionSupport) Error 42: Symbol Undefined _D3com3ibm3icu4text16SimpleDateFormat16SimpleDateFormat7__ClassZ C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(DateConversionSupport) Error 42: Symbol Undefined _D3com3ibm3icu4text16SimpleDateFormat16SimpleDateFormat5_ctorMFAaZC3com3ibm3icu4te xt16SimpleDateFormat16SimpleDateFormat C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(DateConversionSupport) Error 42: Symbol Undefined _D3com3ibm3icu4text10DateFormat10DateFormat7__ClassZ C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(DateConversionSupport) Error 42: Symbol Undefined _D3com3ibm3icu4text16SimpleDateFormat12__ModuleInfoZ C:\Project\dwtinst\dwt-rcp\lib\org.eclipse.core.databinding.lib(DateConversionSupport) Error 42: Symbol Undefined _D3com3ibm3icu4text10DateFormat12__ModuleInfoZ C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(AbstractSet) Error 42: Symbol Undefined _D4java4util18AbstractCollection18AbstractCollection8iteratorMFZC4java4util8Iterat or8Iterator C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(AbstractSet) Error 42: Symbol Undefined _D4java4util18AbstractCollection18AbstractCollection4sizeMFZi C:\Project\dwtinst\dwt-rcp\lib\dwt-base.lib(AbstractSet) Error 42: Symbol Undefined _D4java4util10Collection10Collection7opApplyMFDFKC6ObjectZiZi
Re: Format.convert problme
Qian Xu schrieb: > Hi All, > > tango.text.convert.Format provides a nice function to convert anything > to string. > > It works perfect except the argument is a pointer type. > It will print the address of a pointer instead of its value > > For instance: > int* i = new int; > *i = 10; > Format.convert("{}", i); // <- the address of the pointer > -- > > How to let it print the value instead of the address? > Because I wanna write a dump function to dump the value of any data type > (also void, null) > > > > This is not really an exact answer to your question... :) It seems you want to output trace information. Stdout (which seems you are using) is not thread safe and will generate AV/segf if accessed concurrently. Specially for printing trace info, there is tango.util.log.Trace it is a Stdout replacement that is synchronized, and it also has a memory() function, that lets you print raw memory as a dump.
Re: dsss with dmd2?
Trass3r schrieb: > Frank Benoit schrieb: >> It is set by the compiler. But dsss has an own D compiler included to >> retrieve the imports and pragmas. If you see error messages, they might >> come from the dsss internal DMD frontend. >> You can set the versions in the compiler profile, see dsss/etc/rebuild/ > > Yeah, but I thought rebuild just parses imports and stuff and then calls > dmd to compile all found files, thus D_Version2 should be set by dmd, > shouldn't it? rebuild uses the dmd frontend, so it might also generate errors. And that errors might look exactly the same as those from dmd. And if the rebuild profile is not configured to have D_Version2 set, the frontend might lead you on the wrong track.
Re: dsss with dmd2?
Trass3r schrieb: > I got the dmd2 compiler in the PATH, thus dsss correctly uses phobos > imports and stuff from the dmd2 directory. > BUT what it does not is setting the D_Version2 version??? Why does that > happen, isn't that set by the compiler? It is set by the compiler. But dsss has an own D compiler included to retrieve the imports and pragmas. If you see error messages, they might come from the dsss internal DMD frontend. You can set the versions in the compiler profile, see dsss/etc/rebuild/
Re: digitalmars lib.exe, what does the pagesize mean?
Kagamin schrieb: > Frank Benoit Wrote: > >> What does the pagesize mean? When is it needed to increase? What is the >> cost? > > How's the pagesize related to lib.exe? You should specify context more > precisely. http://www.digitalmars.com/ctg/lib.html The question is about the -p parameter.
digitalmars lib.exe, what does the pagesize mean?
What does the pagesize mean? When is it needed to increase? What is the cost?
Re: idup portable D1/D2
hm, the moment of pressing the "send" button is often enough a moment of enlightment :) version( D_Version2 ){ mixin("invariant(T)[] _idup(T)( T[] str ){ return str.idup; }"); } else { // D1 String _idup( char[] str ){ return str.dup; } } str._idup(); // compiles with D1+D2
idup portable D1/D2
I want to make code compilable with D1+D2. So i thought, i can make version(D_Version2){ } else { // D1 string idup( char[] str ){ return str.dup; } } But this does not work. D1: str.idup; // compile error str.idup(); // OK D2: str.idup; // OK str.idup(); // compile error Ideas?
Re: No map file?
Derek Parnell schrieb: > On Mon, 23 Mar 2009 10:02:28 +0100, Frank Benoit wrote: > >> How can i make DMD (link/optlink) not to generate a map file? >> >> -L/NOM or -LNOMAP >> >> both seem not work. > > You can't using dmd. It doesn't generate the right linker options for you > to avoid the map file. I do it in Bud by not having DMD invoke the linker, > instead I have Bud invoke the linker with the right options. > > The easiest way is to delete the .map files after compiling. > Ok, so i created http://d.puremagic.com/issues/show_bug.cgi?id=2760 Thanks for the answer.
No map file?
How can i make DMD (link/optlink) not to generate a map file? -L/NOM or -LNOMAP both seem not work.
Re: Segfault (NullPointerException) in Linux
Qian Xu schrieb: --- code 2 (current solution) -- > > public test(MyObj obj) > { > if (obj !is null && > obj.getObj2 !is null && > obj.getObj2.getObj3 !is null) > { > obj.getObj2.getObj3.test(); > } > } > > -- If you want to be able to return something like "nothing", you can use NullObject. That is, return an object that lets you navigate the references and lets you test for it being a "null" object. auto o = obj.getObj2.getObj3; if( !o.isNull() ){ o.test(); }
Re: Compare two objects
Frank Benoit schrieb: > (a && a == b) > is sufficient for his use case. Because he wants the way with the least > amount of typing. hm, no :(
Re: Compare two objects
(a && a == b) is sufficient for his use case. Because he wants the way with the least amount of typing.
Re: Deleting an element from an array
nobody schrieb: > "Denis Koroskin" <2kor...@gmail.com> wrote in message > news:op.uor1gzqho7c...@korden-pc... >> On Tue, 03 Feb 2009 15:46:52 +0300, nobody wrote: >> >>> What is the best way to completely remove an element from an array? >>> >>> For example you have an array: >>> [1,2,3,4,5,6] >>> and want to remove element "3" in such a way that the resulting array is: >>> [1,2,4,5,6] >>> >>> Thanks. >>> >>> >> import std.array; >> >> auto arr = [0, 1, 2, 3, 4, 5]; >> >> int lowerBound = 2; >> int upperBound = 4; >> >> // erases elements [lowerBound, upperBound), >> // total of upperBound - lowerBound elements >> arr.erase(lowerBound, upperBound); >> >> assert(arr == [0, 1, 4, 5]); >> > > Ah I'm sorry, I forgot to mention I'm using D1, not D2. > > Thanks for the reply though :) > > arr = arr[ 0 .. lowerBound ] ~ arr[ upperBound .. $ ];
Re: Inheriting from a nested class
llee schrieb: > Is it possible to inherit from a nested class from outside of the enclosing > class? For example: > > class A > { > class B { int x; } > } > > class C : B > { > int get () { return x; } > } > > It should work if B is a static class and you refer to it with A.B . class A { static class B { int x; } } class C : A.B { int get () { return x; } } If the class is not static, it has an implicit "this" pointer of the surrounding class (like in Java), so you cannot create instances of non-static B, if there is no instance of A. static make B independent of this reference.