[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  Compiling the server
. . -> [Subject]  Array Element Type Problem - Smaug 1.4a

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Array Element Type Problem - Smaug 1.4a
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Huxlay   (1 post)  [Biography] bio
Date Fri 06 Aug 2010 11:08 AM (UTC)  quote  ]
Message
Thanks for you information i newly join and your post help me.

Huxlay
[Go to top] top

Posted by Rash   United Kingdom  (56 posts)  [Biography] bio
Date Sun 13 Dec 2009 11:25 AM (UTC)  quote  ]
Message
After some digging, it does indeed seem like Cygwin has been updated with tighter checks. Guess that means I'll be ding a lot of debugging =) At least I'll learn to write much cleaner code.

I'll have to look in to your solution Nick once back on the *nix box.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Fri 11 Dec 2009 07:16 PM (UTC)  quote  ]

Amended on Fri 11 Dec 2009 07:17 PM (UTC) by Nick Gammon

Message
Rash said:


I just can't wrap my head around why it would give such an error now, months after its been compiled cleanly with the strucs been set like that.


If you Google your error message you will find you are not the only one. "But ... it used to work!" is a common theme.

The compiler has tightened up its checks. It now refuses to allocate an array of somethings when it doesn't know what size they are.

This code compiled OK for me:


struct weight_type
{
    char *weight_type_list[1];
};

extern const struct  weight_type     weight_type_table[];

int main ()
{
  return 0;
}


So you may solve your problem by including a .h file that defines what weight_type is, then the extern definition to an array of weight_type can be processed.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Fri 11 Dec 2009 06:39 PM (UTC)  quote  ]
Message
Yes, there was most likely a compiler upgrade, causing it to be more strict about these things.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Hanaisse   Canada  (114 posts)  [Biography] bio
Date Fri 11 Dec 2009 03:33 PM (UTC)  quote  ]
Message
Odd structs aside, if your code hasn't changed has your Cygwin changed? Perhaps some updates have made Cygwin more rigid thus noticing the errors now.

aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
[Go to top] top

Posted by Rash   United Kingdom  (56 posts)  [Biography] bio
Date Fri 11 Dec 2009 02:36 PM (UTC)  quote  ]
Message
What would cause the compiler to give since an error now and not before? I can't seem to get it working at all even with the changes noted above by yourself Nick. (I may be missing something needing done here?)

I just can't wrap my head around why it would give such an error now, months after its been compiled cleanly with the strucs been set like that.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Thu 10 Dec 2009 11:08 PM (UTC)  quote  ]

Amended on Thu 10 Dec 2009 11:09 PM (UTC) by Nick Gammon

Message
I presume these are in different files as you are using extern. Or, if they are in the same file they are in that order.

The compiler cannot determine the size of the array:


extern const struct  weight_type     weight_type_table[];


This compiles and has a similar meaning:


extern const struct  weight_type  *   weight_type_table;


Now all the compiler has to do is allocate space for a pointer.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Rash   United Kingdom  (56 posts)  [Biography] bio
Date Thu 10 Dec 2009 10:20 PM (UTC)  quote  ]
Message
OK I have by far the strangest problem I've ever encountered. Back in march this was compiling clean and without a problem. Just moved it to my new laptop running Cygwin and out pop's this error. The code in question hasn't been changed (Nothing has since March). Any clue's on what may of caused this and how to correct it?

Notes: Codebase is Smaug 1.4a, pretty heavily modified now.

Compile Errors:

make[1]: Entering directory `/home/talairina/src'
gcc -c  -O -g3 -Wall -Wuninitialized    -Dsmaug  -DTIMEFORMAT  act_comm.c
In file included from act_comm.c:32:
mud.h:3868: error: array type has incomplete element type
mud.h:3876: error: array type has incomplete element type
mud.h:3884: error: array type has incomplete element type
mud.h:3892: error: array type has incomplete element type
mud.h:3900: error: array type has incomplete element type
mud.h:3907: error: array type has incomplete element type
mud.h:3909: error: array type has incomplete element type
make[1]: *** [act_comm.o] Error 1
make[1]: Leaving directory `/home/talairina/src'
make: *** [all] Error 2


Lines in question are:


extern const struct  weight_type     weight_type_table[];

struct weight_type
{
    char *weight_type_list[1];
};

/* height table */
extern const struct  height_type     height_type_table[];

struct height_type
{
    char *height_type_list[1];
};


There are more, but all are vastly similar to the above segments.

All compile attempts were on Cygwin under Windows XP SP 3 (Cygwin release is 05 Dec 2009) and Windows 7 (Same Cygwin package). I also attempted this on my Ubuntu box but same error outputs (Ubuntu Linux 8.04.3).
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


3,564 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]