[fpc-devel]CFSTR, some C guru please

Olle Raab olle.r at automagika.se
Mon Aug 16 13:05:53 CEST 2004


> In CFStrings.p compared to CFStrings.h the declaration of CFSTR is
> simply missing, but many other parts of the UI´s rely on it. So, there
> is no other way, the following declaration should be added at line 158:
> 
> function CFSTR(cStr: ConstCStringPtr): CFStringRef; external name
> '___CFStringMakeConstantString';

OK. It seems to have been a C macro.


But I doesn't understand it completely :

In the C headers, the macros is defined as follows:

#define CFSTR(cStr) __CFStringMakeConstantString(cStr "")

... thus calls:

/* This function is private and should not be used directly */
/*
 *  __CFStringMakeConstantString()
 *  
 *  Availability:
 *    Non-Carbon CFM:   not available
 *    CarbonLib:        in CarbonLib 1.0 and later
 *    Mac OS X:         in version 10.0 or later
 */
EXTERN_API_C( CFStringRef )
__CFStringMakeConstantString(const char * cStr);

In the define there is 2 args, but I see only one param in the function
prototype, how come ?


A tip, concerning translation macros: If you cannot do what you did above,
you might write a small function which does what the macro did. The function
can be made inline, to make it as fast as a macro. (Of course not all macros
can be translated to functions)

Olle

BTW Rolf, I divide the discussion in manageble pieces :)





More information about the fpc-devel mailing list