Re: Preprocessor automation to define/declare array of strings

Discussion in 'C Programming' started by Jorgen Grahn, Aug 11, 2012.

  1. Jorgen Grahn

    Jorgen Grahn Guest

    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 .
    Jorgen Grahn, Aug 11, 2012
    #1
    1. Advertising

  2. Jorgen Grahn

    Stefan Ram Guest

    Jorgen Grahn <> 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 )
    Stefan Ram, Aug 11, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cronus
    Replies:
    1
    Views:
    667
    Paul Mensonides
    Jul 15, 2004
  2. marekdec
    Replies:
    0
    Views:
    354
    marekdec
    Jan 5, 2007
  3. apondu
    Replies:
    0
    Views:
    593
    apondu
    Jul 19, 2007
  4. Eric Sosman
    Replies:
    9
    Views:
    645
    Tim Rentsch
    Sep 7, 2012
  5. Ike Naar
    Replies:
    0
    Views:
    341
    Ike Naar
    Aug 6, 2012
Loading...

Share This Page