gcc and initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everybody,

I have some structures in my program, where I could save some space by
overlapping them.

See this example:
	char *yes_no_auto[]= { "auto", "yes", "no" };
	char *yes_no[]= { "yes", "no" };
I know that gcc should fold identical strings in the binary; but if it's
not just strings, but entire structs, this won't help.

Now I wanted to use
	char *yes_no_auto[]= { "auto", "yes", "no" };
	char *yes_no[]=yes_no_auto+1;
but that doesn't work:
	test.c:2: error: invalid initializer

I found that this would work:
	char *yes_no_auto[]= { "auto", "yes", "no" };
	char **yes_no=yes_no_auto+1;

But that won't allow me to use sizeof(yes_no)/sizeof(yes_no[0]) to obtain
the number of elements.

Using "const" doesn't help either.

Any help?


Thank you very much!


Regards,

Phil

-- 
Versioning your /etc, /home or even your whole installation?
             Try fsvs (fsvs.tigris.org)!

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux