Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.c.moderated > #416

Re: "warning: assignment from incompatible pointer type [enabled by default]"

From "LeJacq, Jean Pierre" <jeanpierre.lejacq@quoininc.com>
Newsgroups comp.lang.c.moderated
Subject Re: "warning: assignment from incompatible pointer type [enabled by default]"
Followup-To comp.lang.c.moderated
Date 2013-02-26 10:48 -0600
Organization Quoin Inc
Message-ID <clcm-20130226-0002@plethora.net> (permalink)
References <clcm-20130104-0001@plethora.net>

Followups directed to: comp.lang.c.moderated

Show all headers | View raw


galois271@gmail.com wrote:

> Any help here would be GREATLY appreciated!  Thanks!!!
> 
> Here is my compiler response:
> 
> "gcc "./Desktop/C Programs/HeadFirstTests.c" -o "./Desktop/C Programs/HFT"
> && "./Desktop/C Programs/HFT" ./Desktop/C Programs/HeadFirstTests.c: In
> function ‘addFirst’: ./Desktop/C Programs/HeadFirstTests.c:40:16: warning:
> assignment from incompatible pointer type [enabled by default] ./Desktop/C
> Programs/HeadFirstTests.c: In function ‘printList’: ./Desktop/C
> Programs/HeadFirstTests.c:51:7: warning: assignment from incompatible
> pointer type [enabled by default] "
> 
> 
> /* This program builds
>    a basic linked list.
>    gcc "./Desktop/C Programs/HeadFirstTests.c" -o "./Desktop/C
>    Programs/HFT" && "./Desktop/C Programs/HFT"
> */
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> 
> typedef struct {           // Define a linked list node
>      char *name;
>      struct LLNODE *next;
> }LLNODE;

You are attempting to declare next with a yet undefined type. You must first 
make declare the struct.

/* Declaration of struct. */
struct LLNODE;

/* Declaration of typedef. */
typedef struct LLNODE LLNODE;

/* Definition of struct. */
struct LLNODE {
   char *name;
   struct LLNODE *next;
};

As a bonus tip, use of all upper case for names of structs is poor style. 
These should be reserved for macros.

-- 
JP
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

Back to comp.lang.c.moderated | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

"warning: assignment from incompatible pointer type [enabled by default]" galois271@gmail.com - 2013-01-04 18:14 -0600
  Re: "warning: assignment from incompatible pointer type [enabled by default]" "LeJacq, Jean Pierre" <jeanpierre.lejacq@quoininc.com> - 2013-02-26 10:48 -0600
  Re: "warning: assignment from incompatible pointer type [enabled by default]" espie@lain.home (Marc Espie) - 2013-02-26 10:51 -0600
  Re: "warning: assignment from incompatible pointer type [enabled by default]" Barry Schwarz <schwarzb@dqel.com> - 2013-02-26 10:47 -0600
  Re: "warning: assignment from incompatible pointer type [enabled by default]" Jasen Betts <jasen@xnet.co.nz> - 2013-02-26 10:51 -0600
  Re: "warning: assignment from incompatible pointer type [enabled by default]" Andrei Voropaev <avorop@mail.ru> - 2013-02-26 10:51 -0600
  Re: "warning: assignment from incompatible pointer type [enabled by default]" gordonb.zh6m9@burditt.org (Gordon Burditt) - 2013-02-26 10:51 -0600

csiph-web