This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strings and char *


Hi Michael,

this is not really a gcc related question, but to shorten this: color and r differ in types, that's why you are getting an error.

Regards

-Sven


Michael Surette wrote:
It's been a while since I've written any C code, so please forgive me if
this is a newbie type question.

I was having a problem with a larger program when I ran into a problem. The
following code snippet should work according to what I remember of C. What's wrong with it?


------------

char * color;
char * r="red";
color = r;

------------

gcc -c ar.c

------------

ar.c:3: error: conflicting types for 'color'
ar.c:1: error: previous declaration of 'color' was here
ar.c:3: warning: initialization makes integer from pointer without a cast
ar.c:3: error: initializer element is not constant
ar.c:3: warning: data definition has no type or storage class

------------

gcc --version

------------

gcc (GCC) 3.4.4
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]