Re: Ah've got them Function Pointer blues
- From: "MikeC" <Mike.Best@xxxxxxxxxxxxx>
- Date: Fri, 22 Aug 2008 14:31:52 +0100
"August Karlstrom" <fusionfile@xxxxxxxxx> wrote in message
news:g8jtk7$me6$1@xxxxxxxxxxx
MikeC wrote:
[...]
I would like to have an array of structures, something like
struct FS
{ <function pointer>;
<some other variables>;
};
My problem is that the <function pointer> is of unknown type - in
function_structure[2] it may be
int func_1(int, int) {....}
in function_structure[5], it may be
void func_2(char **cpt) {....}
etc.
How come the functions have different signature and what do you want to
achieve? Please, tell us a bit more about the underlying problem.
August
Well, I would have done that in the first place, but that's to do with
architecture, not with C, and this is a C group, and flames burn me. In my
original post, I asked:
"Incidentally, this may not be the best way to design the program, so I'd
like to ask about that too.
Can anybody suggest a newsgroup? (program architecture isn't really C)"
However, as you ask ...
I haven't finished specifying the program yet - I keep having bigger and
better ideas - but I want to write a text macro engine. It will interpret
commands from a (text) command file, executing them on an input (read only)
file, and producing an output file. The commands will be, for example
copy off // don't copy anythying from the input file to the output file
find_forward "a text string"
move_left 6 // characters
copy on // this causes any character scanned by the cursor to be copied to
the output file
loop 6 // times
{ <more commands>
}
etc....
.... you get the idea.
I wanted to run through the command (program) file and compile it into a
forth-like stack (yes, I'm a dinosaur), with each stack element being a
structure, which contains, among other things, a pointer to the function
that will execute the command. The commands do different things, so they
have different signatures, hence my question.
Among all the ways of solving this problem (the architecture problem), I'm
sure people who have spent a life in preofeesional programming will know of
much better methods, and probably be able to pull in other
packages/libraries that would do a lot of the work - but I don't know about
those. I usually write programs from scratch, and write everything.
Last night, I wrote char *stristr(char *str) because it isn't in the
library - though I'm sure it's somewhere (though I wouldn't know where to
look). I'm rather pleased with it! :-)
Regards,
MikeC
.
- Follow-Ups:
- Re: Ah've got them Function Pointer blues
- From: Ben Bacarisse
- Re: Ah've got them Function Pointer blues
- References:
- Ah've got them Function Pointer blues
- From: MikeC
- Ah've got them Function Pointer blues
- Prev by Date: Re: About MSIL Disassembler
- Next by Date: Re: why dosent buffer gets overflowed
- Previous by thread: Re: Ah've got them Function Pointer blues
- Next by thread: Re: Ah've got them Function Pointer blues
- Index(es):
Relevant Pages
|