[OCLUG-devel] one more question about structures...

James Colannino james at colannino.org
Sat Jun 19 19:12:39 PDT 2004


Christopher Smith wrote:
> On Sat, 2004-06-19 at 18:32, James Colannino wrote:
> 
>>Ok, I have one more question about structures...  I hope that these 
>>three messages I've sent to the group in the past 30 minutes or so 
>>haven't gotten annoying.  I haven't seen any activity on the oclug-devel 
>>list lately, so I'm hoping that at least people will be happy that 
>>there's some traffic :-P
>>
>>This isn't about anything going wrong.  I'm just curious about a benign 
>>compiler warning that I'm getting.  Consider the following code:
>>
>>#include <stdio.h>
>>
>>int main()
>>
>>{
>>	struct time {
>>		unsigned short int hour;
>>		unsigned short int min;
>>	};
>>
>>	struct date_time {
>>		unsigned short int month; /* 1-12 */
>>		unsigned short int day;   /* 1-31 */
>>		unsigned short int year;
>>
>>		struct time time_of_day;
>>	} date;
>>
>>	date.time_of_day.hour = 1;
>>
>>	return 0;
>>}
>>
>>Whenever I assign a value to a nested structure, I get the following 
>>warning from the compiler:
>>
>>warning: declaration does not declare anything
> 
> 
> Hmm... shouldn't it be:
> 
> typedef struct date_time {
> 	/* stuff */
> } date;
> 
> Does that make the compiler warning go away?

Nope, that makes it compile with an error instead :-P  What's weird is 
that the code I have above compiles with a warning on my laptop (but it 
still works), but not on my desktop machine.  Weird...

James
-- 
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"There are no uninteresting things; only uninterested people." --G.K. 
Chesterton



More information about the OCLUG-devel mailing list