[FFmpeg-devel] Question: declare common function pointers

Howard Chu hyc
Thu Jun 10 21:04:35 CEST 2010


Maxim wrote:
> Hi,
>
> I wish to declare two common function pointers shared between
> indeo4/indeo5 (see the attached patch). Is the "ff_" prefix required in
> this case?

Just a side note, sorry I have no answer to the original question...

This is not the ideal way to typedef function pointers. You should always 
typedef the actual base type, not (only the) pointer to type. Then you can use 
the typedef in declarations. Otherwise, the typedef is of only limited usefulness.

E.g., use this:

typedef void (InvTransformFunc)(arg1, arg2, arg3);

Then in other headers you can declare

InvTransformFunc MyTransform;

So that when you actually write the code for MyTransform, the prototype will 
be type checked by the compiler.

And of course, in your references, you just use

typedef struct foo {
	...
	InvTransformFunc *inv_transform;
	...
} foo;

And then it's not necessary to comment "inverse transform function pointer" - 
it's already obvious from the text.
-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/



More information about the ffmpeg-devel mailing list