I'm going through some C++ code that someone else wrote trying to
understand it. One part I have some questions about is the following:
//*****************************************************
static UDPPrimitiveTypeInfo primitiveInfo =
{
"Rectangular Spiral",
"Create a Rectangular Spiral in XY plane",
"Ansoft Cor****ation",
"01-01-2004",
"1.0"
};
extern "C" DLLEX****T
UDPPrimitiveTypeInfo* GetPrimitiveTypeInfo()
{
return &primitiveInfo;
}
//*****************************************************
The first part is clear. It's just defining a static structure,
"primitiveInfo" of type "UDPPrimitiveTypeInfo" which contains a number
of character fields.
The second part (extern "C" DLLEX****T) I'm not so sure about. What does
it do?
The last part is what I'm mainly questioning. If I understand this
correctly, it looks like it's a function that returns a pointer to a
structure (I believe that's what "UDPPrimitiveTypeInfo*" type is
specifying), and the return value is the address of the previously
defined structure, "primitiveInfo". - Is that correct?
If so, wouldn't it be easier to just assign the address directly, ie.
UDPPrimitiveTypeInfo * GetPrimitiveTypeInfo = &primitiveInfo;
rather than use a function? Is there some benefit to using a function?
Thanks for any feedback on this.


|