Re: reviving games/freebsd-games

On Tue, 28 Oct 2008 13:03:32 +0100 clemens fischer wrote:

On Tue, 28 Oct 2008 11:57:15 +0100 Jurjen Middendorp wrote:

If you do char *p = "something", you can't write to that string
(it's a pointer into some stringtable: easy way to look at it
:). You have to use char p[] = "something", then it's an array
with enough storage to write to :) maybe try something like char
scrollname[NUMSCROLLS][]; ?

this type of declaration evokes "array type has incomplete element
type", which is seen as compliant behaviour by gcc experts. so this is
a no go.

I thought I'd clean up that code declaring a real struct like:

struct scrollname_s {
int active;
char name[] = "...";

this is what i actually did. it makes the code way more easier to read
and keep.

then name could stay read-only. OTOH I found numerous larn versions,
so keeping ours "compatible" might keep maintenance costs down.

I'd still be interested in what others did.


freebsd-questions@xxxxxxxxxxx mailing list
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"

Relevant Pages

  • Re: Memory Structure Pointer Problems
    ... typedef struct sta { ... char* name; ... int num_cmpnds; ... A pointer to a struct cmp is almost ...
  • Re: Exporting a structure
    ... A Structure is like a char array. ... A struct looks like this. ... The following gets a double pointer to the first element of the array. ... We could have done something weird, like getting an int from a double. ...
  • Re: oops in uevent_helper [was: mmotm 2010-01-13-12-17 uploaded]
    ... rather than a static char array. ... that the sysfs path could copy data to that pointer safely. ... struct kobj_attribute *attr, char *buf) ...
  • Re: usage of size_t
    ... where does the pointer point? ... each allocated "struct foo" contains the associated data. ... infer that he thinks that all linked lists must be char. ...
  • Re: Difference between Char* ptr and char arrCh []
    ... Is there a difference in storage of global char* and char* inside a ... The pointer is stored in automatic storage. ... and the pointer globalCh must be writable. ...