🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15038

Insérer une fonctions dans une structure?

#15038
From: frederic
Date: Sat, 15 Oct 2005 17:34
36 lines
1531 bytes
Bonjour,

y-a-t'il moyen en C, d'ins�rer une ou des fonctions dans une structure de donn�es?

typedef struct Complex Complex;
struct Complex {
     int value;
     int (*fn)();
     char *mesg;
};

Lorsque je compile comme �a, le compilo ne cris pas, mais par
contre, il hurle si j'ai la d�claration suivante:

Complex table[] = {
     ONE, double(ONE), "premier message",
     TWO, double(TWO), "deuxi�me message",
     THREE, double(TREE), "troisi�me message",
     FOUR, double(FOUR), "quatri�me message",
};

pour info:
int double(int i)
{
     return i * i;
}

enum {
     ONE = 10,
     TWO,
     THREE,
     FOUR,
};
-- 
Fr�d�ric
Technical Details
Message-ID: <87r7amd6qx.fsf@venus.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!usenet-fr.net!news.enst.fr!grolier!v.t-online.fr!t-online.fr!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,d00d98e8032f6fc,start
X-Google-Attributes: gidf9822,public
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!usenet-fr.net!news.enst.fr!grolier!v.t-online.fr!t-online.fr!not-for-mail
Newsgroups: fr.comp.lang.c
Subject: Insérer une fonctions dans une structure?
From: frederic@askme.fr
Organization: F(x)
X-Troll: Vi is better than Emacs
Date: 15 Oct 2005 19:34:14 +0200
Message-ID: <87r7amd6qx.fsf@venus.net>
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Lines: 36
NNTP-Posting-Date: 15 Oct 2005 17:33:47 GMT
NNTP-Posting-Host: 195.36.227.46
X-Trace: 1129397627 news.club-internet.fr 452 195.36.227.46
X-Complaints-To: abuse@club-internet.fr