|
From: | Daniel J Sebald |
Subject: | Re: sig2str and str2sig use in C++ |
Date: | Mon, 03 Jun 2013 17:47:36 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16 |
On 06/03/2013 05:28 PM, Paul Eggert wrote:
How about the following idea instead? Have sig2str.h export an array like this: extern char const allsigstr[]; This would consist of a concatenation of null-terminated strings, one per name, terminated by an empty string. allsigstr could be initialized at compile-time, with no runtime actions needed. Since it's read-only and initialized it could be put into the text segment. The existing numname_table could remove its 'name' field, and replace it with an integer offset into allsigstr. This offset could also be calculated at compile-time, so numname_table could live in the text segment too.
Much simpler syntax than the typedef I used (and than a structure). I tried to think of a method not involving run-time array initialization, but couldn't. You're idea for use of an index in the structure rather than the actual string is a good one. Choose whatever nomenclature for "allsigstr" that makes sense.
Thanks, Dan
[Prev in Thread] | Current Thread | [Next in Thread] |