www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/29/12:17:40

From: Vic <tudor AT cam DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: weird error: pointers to functions in structs
Date: Sat, 29 Nov 1997 10:09:24 -0500
Organization: Communications Accessibles Montreal, Quebec Canada
Lines: 23
Message-ID: <34803024.7A6F@cam.org>
NNTP-Posting-Host: dynamicppp-223.hip.cam.org
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm building a GUI for a project at school. My button structure is:
typedef struct 
{
int x,y,w,h;
void (*action) (void);
int raised;
char *text;
int clickable;
} Tbutton;

I initialise a button as
Tbutton load={215,60,70,20,NULL,1,"Load",0};
here the function is NULL because I haven't implemented it yet :)
Anyways, I have an array of buttons. (but)
If I say
but[number].(*action)(); I get a parse error before "("
but if I say
void (*thing)();
thing=but[number].action;
(*thing) ();
it works and calls the right function. Why?
-- 
--> http://www.cam.org/~tudor <--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019