Question: ```

extern "C" {
    typedef struct Pair_s {
        char *first;
        char *second;
    } Pair;

    typedef struct PairOfPairs_s {
        Pair *first;
        Pair *second;
    } PairOfPairs;
}

Pair pairs[] = {
    {"foo", "bar"}, //this is fine
    {"bar", "baz"}
}; 

PairOfPairs pops[] = {
    {{"foo", "bar"}, {"bar", "baz"}}, //How can i create an equivalent of this NEATLY
    {&pairs[0], &pairs[1]} //this is not considered neat (imagine trying to read a list of 30 of these)
}; 

```

How can I achieve the above style declaration semantics?

Answer: 
In C++11 you could write:

```
PairOfPairs pops[] = {
    { new Pair{"a", "A"}, new Pair{"b", "B"} },
    { new Pair{"c", "C"}, new Pair{"d", "D"} },
    // the grouping braces are optional
};

```

Do note the implications of using the free store: objects allocated there are not destructed at the end of the execution of your program (like static objects are) or anytime else (without a corresponding `delete`). Probably not a concern in hosted implementations if Pair is a C struct and does not manage resources (and you always expected your program to use that memory until it exits).

edit: If you can't use C++11 features, you can always create a helper function. Example:

```
static Pair* new_pair(const char* first, const char* second)
{
    Pair* pair = new Pair;
    pair->first = first;
    pair->second = second;
    return pair;
}

```
This is a case where I think macros would increase the readability of your code. You could create an unguarded include file:

```
/* file: pairs.def */
PAIR_DEF(foo, bar)
PAIR_DEF(bar, baz)
//...

```

When you initialize your `pairs` array, you would use this file:

```
Pair pairs[] = {
#define PAIR_DEF(x, y) { #x, #y },
#include "pairs.def"
#undef PAIR_DEF
};

```

And you can create corresponding enumerated constants:

```
enum PairEnum {
#define PAIR_DEF(x, y) PAIR_ ## x ## _ ## y,
#include "pairs.def"
#undef PAIR_DEF
};

```

Then create a helper macro to help you initialize your `pops` array.

```
#define PAIR(x, y) &pairs[PAIR_ ## x ## _ ## y]
PairOfPairs pops[] = {
    { PAIR(foo, bar), PAIR(bar, baz) },
    //...
};

```

This is similar to the technique I use to associate `enum` values to strings, described in my answer to [this question](https://stackoverflow.com/questions/3342726/c-print-out-enum-value-as-text).