Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2000:
[Freeciv-Dev] Re: TODO
Home

[Freeciv-Dev] Re: TODO

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jules Bean <jules@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cc: Erik Sigra <freeciv@xxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: TODO
From: Greg Wooledge <wooledge@xxxxxxxxxxx>
Date: Fri, 22 Sep 2000 07:31:15 -0400

Jules Bean (jules@xxxxxxxxxxxxxxxxxxxxxxxxx) wrote:

> 'on-the-fly' struct creation is not possible.
> 
> Instead use a 'constructor' function
> 
> struct locus make_locus(int x,int y) {
>   struct locus l;
>   l.x=x; l.y=y;
>   return l;
> }

jekyll:~$ cat foo.c
#include <stdio.h>
struct foo {
        int x;
        int y;
};
int main(void) {
        struct foo bar = { 1, 2 };
        printf ("%d\n", bar.x + bar.y);
        return 0;
}
jekyll:~$ gcc -O -g -Wall -ansi -pedantic -o foo foo.c
jekyll:~$ ./foo
3

-- 
Greg Wooledge                    | "Truth belongs to everybody."
wooledge@xxxxxxxxxxx             |   Red Hot Chili Peppers
http://www.kellnet.com/wooledge/ |

Attachment: pgp5fzRAD5bh_.pgp
Description: PGP signature


[Prev in Thread] Current Thread [Next in Thread]