Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Structs with pointers

Reply
Thread Tools

Structs with pointers

 
 
Hanno Boettcher
Guest
Posts: n/a
 
      06-27-2004
Hi there,

I got a little problem with a program I'm writing:

I use some structs, the definitions are as follows:

struct GitterPunkt{
float a[ANZ_SENSOREN];
float d[ANZ_SENSOREN];
float p[ANZ_SENSOREN];
float p4ges;
float p3ges;
float r;
float phi;
};

struct ErgMax{
struct Gitterpunkt *randlinks;
struct Gitterpunkt *randrechts;
struct Gitterpunkt *randunten;
struct Gitterpunkt *randoben;
struct Gitterpunkt *max3;
struct Gitterpunkt *max4;
};

struct GitterPunkt gitter[N][M]; /* N and M are definde like #define M
10 */

struct idl{
char id[ANZ_SENSOREN];
struct ErgMax *erg;
struct idl *next;
};


My Program is a bit long to post it here, but I think there are only few
lines important:

struct idl *aktid=0;
/* some code, aktid changes to !0 */
aktid->erg->randoben=&gitter[i][j]; /* it's in a loop with i and j for
counters */

I have got several assignments like the one above and I get the same
compilation error everytime:

auswerten.c:73: Warnung: Zuweisung von inkompatiblem Zeigertyp

Because I use a german system the warning is in german, too. In english
it's something like: "auswerten.c:73: Warning: Assigment with
incompatible Pointertype" (free translated)

I'm puzzled, I don't have any clue what is going wrong. Does anybody
here got an idea?

Normaly randoben should get a pointer to a Gitterpunkt (fix in i and j),
but the compiler says, that the pointer are incompatible...

Thx in advance
 
Reply With Quote
 
 
 
 
Irrwahn Grausewitz
Guest
Posts: n/a
 
      06-27-2004
Hanno Boettcher <(E-Mail Removed)> wrote:
>Hi there,
>
>I got a little problem with a program I'm writing:
>
>I use some structs, the definitions are as follows:
>
>struct GitterPunkt{

[...]
>};
>
>struct ErgMax{
> struct Gitterpunkt *randlinks;
> struct Gitterpunkt *randrechts;
> struct Gitterpunkt *randunten;
> struct Gitterpunkt *randoben;
> struct Gitterpunkt *max3;
> struct Gitterpunkt *max4;

^--- How a simple typo can mess things up.

struct Gitterpunkt != struct GitterPunkt

Regards
--
Irrwahn Grausewitz ((E-Mail Removed))
welcome to clc: http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc OT guide : http://benpfaff.org/writings/clc/off-topic.html
 
Reply With Quote
 
 
 
 
Emmanuel Delahaye
Guest
Posts: n/a
 
      06-27-2004
In 'comp.lang.c', Hanno Boettcher <(E-Mail Removed)> wrote:

> struct GitterPunkt{

<...>
> struct Gitterpunkt *randunten;

<...>
> struct GitterPunkt gitter[N][M]; /* N and M are definde like #define M
> 10 */

<...>

Check you code one more time: 'GitterPunkt' is not 'Gitterpunkt'. C is case
sensitive.

--
-ed- get my email here: http://marreduspam.com/ad672570
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
 
Reply With Quote
 
Hanno Boettcher
Guest
Posts: n/a
 
      06-27-2004
Emmanuel Delahaye wrote:
> In 'comp.lang.c', Hanno Boettcher <(E-Mail Removed)> wrote:
>
>
>>struct GitterPunkt{

>
> <...>
>
>> struct Gitterpunkt *randunten;

>
> <...>
>
>>struct GitterPunkt gitter[N][M]; /* N and M are definde like #define M
>>10 */

>
> <...>
>
> Check you code one more time: 'GitterPunkt' is not 'Gitterpunkt'. C is case
> sensitive.
>


AHHH, thx!
<-- I'm with stupid
 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      06-27-2004

"Hanno Boettcher" <(E-Mail Removed)> wrote
>
> AHHH, thx!
> <-- I'm with stupid
>

This is an argument for typedefing your structs.

typedef struct
{
int x;
/* blah */
}GitterPunkt.

Now if you type

Gitterpunkt *ptr;

the compiler should tell you that the declaration is invalid because it
doesn't understand the identifier, rather than down the line when it tries
to match up the struct.

However I'm surprised that a German should make an error in use of capitals.


 
Reply With Quote
 
Hanno Boettcher
Guest
Posts: n/a
 
      06-28-2004
Malcolm wrote:
> "Hanno Boettcher" <(E-Mail Removed)> wrote
>
>>AHHH, thx!
>><-- I'm with stupid
>>

>
> This is an argument for typedefing your structs.
>
> typedef struct
> {
> int x;
> /* blah */
> }GitterPunkt.
>
> Now if you type
>
> Gitterpunkt *ptr;
>
> the compiler should tell you that the declaration is invalid because it
> doesn't understand the identifier, rather than down the line when it tries
> to match up the struct.
>
> However I'm surprised that a German should make an error in use of capitals.

Even Germans aren't perfect
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Packed structs vs. unpacked structs: what's the difference? Daniel Rudy C Programming 15 04-10-2006 08:10 AM
Array of structs instead of an array with pointers to structs? Paminu C Programming 5 10-11-2005 07:18 PM
length of an array in a struct in an array of structs in a struct in an array of structs Tuan Bui Perl Misc 14 07-29-2005 02:39 PM
const structs in other structs Chris Hauxwell C Programming 6 04-27-2004 07:03 PM
structs with fields that are structs Patricia Van Hise C Programming 5 04-05-2004 01:37 AM



Advertisments