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

James Colannino james at colannino.org
Sat Jun 19 18:32:10 PDT 2004


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

However, when I run my program (I also have a printf() in there to test 
that the value has been assigned), it shows me that it indeed was 
declared.  I'm confused...

By the way, I know that I could just do away with the nested structure 
and have the hour and min variables be a part of the first structure, 
thereby eliminating unnecessary confusion, but I just did this to serve 
as an example.

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