Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: Preprocessor automation to define/declare array of strings (http://www.velocityreviews.com/forums/t949723-re-preprocessor-automation-to-define-declare-array-of-strings.html)

Jorgen Grahn 08-11-2012 06:09 AM

Re: Preprocessor automation to define/declare array of strings
 
On Mon, 2012-08-06, pozz wrote:
> I have a lot of array of strings defined in strings.c and declared in
> strings.h.


....
> As you can understand, maintain synchronized strings.c and strings.h can
> be tedious: when I add a list in strings.c, I have to remember to add it
> in strings.h also and I have to take care to use the same name.


Why? As far as I can tell, you'll get a compilation/linking error if
you make any significant mistake here.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Stefan Ram 08-11-2012 05:31 PM

Re: Preprocessor automation to define/declare array of strings
 
Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
>On Mon, 2012-08-06, pozz wrote:
>>I have a lot of array of strings defined in strings.c and declared in
>>strings.h.

>...
>>As you can understand, maintain synchronized strings.c and strings.h can
>>be tedious: when I add a list in strings.c, I have to remember to add it
>>in strings.h also and I have to take care to use the same name.

>Why? As far as I can tell, you'll get a compilation/linking error if
>you make any significant mistake here.


Many software projects fail, and I presume this also applies to projects
using C. But what pozz mentions AFAIK is never a reason for such a failure.
In other words: That is only a minor problem in C software development.

Some even see the clear distiction between then interface (in the header
file) and then implementation (in the .c/.o file) as an advantage of C.

It is also not strictly redundant, IIRC one can declare

void example( int x );

and later start the definition with

void example( int const x )



All times are GMT. The time now is 08:12 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.