Newbie GDC issues
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Sep 5 16:56:40 PDT 2013
On Fri, Sep 06, 2013 at 01:49:17AM +0200, Ramon wrote:
> On D's, and in particular GDC's, way to conquer the world there will
> evidently be many newbies to notice D, look at it, be drawn to it
> (and be happily trapped).
>
> I am such a newbie and the idea behind this thread is to collect all
> the issues, quirks and nuisances a newbie might encounter.
> Please note that quite typically this is not to do with GDC being at
> fault but rather with a newbie naturally not yet knowing all the ins
> and outs (like, e.g. that with GDC one must use "-fdebug" and not
> "-debug" as with dmd).
Note that -fdebug isn't the only one you have to watch out for. A *lot*
of DMD options are renamed in GDC (mainly due to conflicts with GCC
native options). Most of them are just prepended with -f (like -debug =>
-fdebug) but there are some that are complete renames (like -D => -fdoc)
and syntax rewrites (-Dddocdir => -fdoc-dir=docdir).
The gdc manpage should be consulted when in doubt.
> I assume that for most issues someone more experienced will step in
> and provide an explanation, a solution or a workaround or just some
> magic *g
>
> So, here goes:
>
> -------------
>
> char[] someDynArray;
>
> // in main, after someDynArray is somehow init'd...
>
> char c;
> for(int i = 0; i < someDynArray; i++)
> c = someDynArray[i];
>
> Now, in the debugger:
>
> >print someDynArray
> // whatever it happens to hold. Works fine.
>
> >print someDynArray[i]
> Structure has no component named operator[].
>
> Any ideas?
Hmm. Maybe try someDynArray.ptr[i]? (Caveat: I never tried this before,
so dunno if it will work.)
@Iain: on that note, it looks like gdb thinks it's debugging C++, but D
doesn't have anything called 'operator[]'. It would be Really Nice if we
could somehow coax gdb to use opIndex instead (though it doesn't really
help in the case of dyn arrays 'cos they are built-in, and don't
actually have any opIndex to speak of).
T
--
Never step over a puddle, always step around it. Chances are that
whatever made it is still dripping.
More information about the D.gnu
mailing list