Re: Strange C error
- From: Adam <news@xxxxxxxxxxxxxxxx>
- Date: Mon, 17 Dec 2007 11:01:43 GMT
In message
<6b7f18f3-f9a0-4c1d-930d-757cd2716b65@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
davehigton wrote:
On 16 Dec, 23:46, Martin Wuerthner <spamt...@xxxxxxxxxxxxxxx> wrote:
In message <10e94e524f.davehigton@xxxxxxxxxxxxx>
Dave Higton <davehigton@xxxxxxxxxxxxx> wrote:
I've checked, by using Error_Report (), what is in the various
buffers, including "line".
Getting debug output back via wimp error boxes sounds a bit painful!
Unless there's a specific reason for doing it that way, there're a
couple of alternatives. DeskLib provides a Debug module which has a
"Debug_Printf" function which you can write to using the syntax of the
printf family of functions. The debug output is automatically removed
from your code when you /don't/ define DeskLib_DEBUG. When you /are/
debugging, the output can appear in a taskwindow. However, in version
2.80 using the Debug module is a bit clumsy as you have to link with
another bit of library.
The current development version of DeskLib makes things a bit more
straightforward and offers the option of using Martin Avison's excellent
Reporter to show the output instead. This is what I do. [1]
Possibly the easiest solution for you would be to just use the Reporter
SWI yourself in a debug function. Something like:
SWI(1 ,0 , 0x054C80 | XOS_Bit, text);
where 'text' is a char pointer to your debug text.
Or you could borrow someone else's code, e.g. from DeskLib:
http://tinyurl.com/3akzce
http://tinyurl.com/35bs7n
I've done some more investigation, and I can see a change thatThat may be the length of the text contained in the icon, but what
kills it, though I still don't know why it does so. The (by now
much shortened) version of CreateCommand () is:
char username[64];
[...]
/* Extract the username and realm from the icon */
Icon_GetText (mainh, MAIN_USERNAME, username);
[...]
If I delete the "Icon_GetText (mainh, MAIN_USERNAME, username);"
line (and the Error_Report 2 lines later), it doesn't crash.
The Error_Report line is something I added /after/ discovering
that the presence of the line made the difference; it shows that
what is in username is what I expect, and is 7 characters long
plus terminator: it's "1988290".
is the length of the icon's buffer (as set in the templates file)?
A quick look at the Icon_GetText sources reveals that it usually
overwrites as much memory as specifed in the icon definition, not
only as much as currently used by the contents of the icon.
I've only had a quick glance at the source, but do you mean that the
line
strncpy(text, buffer, len);
will write the whole of the indirected icon's 'buffer' into 'text' if
the string is CR-terminated? If so, changing it to
strncpycr(text, buffer, len);
and adding
#include "DeskLib:Str.h"
ought to do the trick. Hmm, looks like the termination section seems to
go round the houses a bit too...
Oh, good grief. That'll be it, then.
To be fair, the function description does say "the minimum [size is] the
size of the [indirected] icon's buffer". I agree it's not particularly
clear though! I'll change that, at least.
And I can see a swift modification to my copy of Icon_GetText ()
coming up, too.
If you're feeling community-minded, feel free to feed back any
improvements. :)
Is there a limit to how much char[] space I can create as local
variables in a function with gcc?
I have no idea, but in general GCC would be the last place I'd look for
bugs or unexpected or restrictive behaviour. ;)
I haven't built DeskLib since I downloaded it; should I rebuild
it under gcc?
I don't think so. What would you be looking to achieve? DeskLib 2.80 was
built using GCC 3.4.6.
Cheers,
Adam
[1] If it is helpful I could send you a pre-built version of the
development version.
--
Adam Richardson Carpe Diem
http://www.snowstone.org.uk/riscos/
.
- Follow-Ups:
- Re: Strange C error
- From: Martin Wuerthner
- Re: Strange C error
- References:
- Strange C error
- From: Dave Higton
- Re: Strange C error
- From: Martin Wuerthner
- Re: Strange C error
- From: Dave Higton
- Re: Strange C error
- From: Martin Wuerthner
- Re: Strange C error
- From: davehigton
- Strange C error
- Prev by Date: Re: Strange C error
- Next by Date: Re: Strange C error
- Previous by thread: Re: Strange C error
- Next by thread: Re: Strange C error
- Index(es):
Relevant Pages
|
|