Hi,

I've found that the definition of some constants like RT_RCDATA
or IDI_EXCLAMATION from the latest RC1 is a little bit strange.
These "constants" are defined as functions, which return a value
using the function MakeIntResource, which in turn does a type
casting from integer to LPTSTR. So all this only does returning
a fixed integer value as LPTSTR.

Why do this? Even if inline functions would remove most of the
overhead, it seems odd. The compiler perfectly understands a
type cast in a constant definition like

const TestConst = LPTSTR(5);

At least in Delphi mode this compiles fine. I didn't check the
other modes, though.

Another side effect of this function approach is that these
"constants" can never be used as values for default parameters.
The following function does not compile in FPC 1.9.6, but works
fine in Delphi:

function GetResource(
  lpszName : PChar;
  szType   : PChar = RT_RCDATA;
  hInst    : HINST = 0) : Pointer;

  
Bye,

 Frank


_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to