expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
// I thought my C code was the best
// But GCC says it's broken
// Expected equal, comma, semi
// Asm or attr before star token
#include <stdlib.h>
struct Point { float x; float y; };
typedef char const * PlaceName;
struct Location Site;
struct Location {
struct Point coords;
PlaceName const placeName;
};
struct Atlas {
unsigned short int length;
struct Location locs[]; // "locs-array"
};
extern struct Location *
search(struct Atlas *ap,
PlaceName name);
extern struct Atlas *readFromHD();
#include <stdio.h>
extern void printToStream(struct Location const *l,
FILE *fd);
#include <assert.h>
#ifdef NDEBUG
# error "assertions must be on"
#endif // catch ALL the bugs!
#include <errno.h>
static int isDone;
int main(int count, char **args) {
assert(count > 1); // "count more than 1"
struct Atlas *theData = readFromHD();
while (++args, --count) {
struct Location *lp;
lp = search(theData, *args);
assert(lp != NULL);
printToStream(lp, stdout);
isDone = !errno;
if (isDone)
exit(1);
// else process the rest
}
// we left the loop, all args consumed
return EXIT_SUCCESS;
}
// TODO: Should clean up global vars.
// Is 'Site' still used? Where?
// FIXME: this line does not compile:
Atlas *syntaxError; // should be "struct Atlas"
Bluh. Spent too much time on that.
Part of Poem-a-Day 2013. Title donated by Hoa-Long T.