Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM handling of C declarations
#7
Quote:Less * and & in code.
In C/C++ also easier to access members. C++ example with *&: x->m. C++ example with **: (*x)->m. QM does not have -> and instead allows x.m in all cases where possible.

Ok, i think under the hood, QM has some optimisation and internal casting for making things easier, the same as passing a variable using +operator, which can be confusing when used to genuine syntax..but ok for me, as long i can "connect" both syntaxes...maybe less * or & are good after all

Quote:Type PMIB_IPINTERFACE_ROW probably is a typedef or #define for MIB_IPINTERFACE_ROW*. Like the famous LPSTR actually is char*. When you see P or LP at the beginning of a type name in C/C++ code, it is probably a pointer. Microsoft always uses this naming convention.

oops, missed that, yes it's in the MSDN declaration, my bad, so focused on MIB_IPINTERFACE_ROW of QM that i did not see it, yes indeed in example, it refers to a pointer, so your conversion is correct (how could it be different anyway)....


typedef struct _MIB_IPINTERFACE_ROW {
ADDRESS_FAMILY Family;
NET_LUID InterfaceLuid;
NET_IFINDEX InterfaceIndex;
.../...
} MIB_IPINTERFACE_ROW, *PMIB_IPINTERFACE_ROW;


Quote:the PMIB_IPINTERFACE_ROW row variable which must be filled is not declared anywhere
I see that the callback calls interfaceChanged(), which calls GetIpInterfaceEntry() (WinAPI) and passes the same row variable, not another MIB_IPINTERFACE_ROW variable.

Exactly, so my question stands: how can a function initialize a variable not even declared in the main code????????

static void WINAPI InterfaceChangeCallback(PVOID callerContext,
PMIB_IPINTERFACE_ROW row,
MIB_NOTIFICATION_TYPE notificationType) <--------- Main callback function, waiting for the unknow MIB_IPINTERFACE_ROW pointer
{
.....
notifier ->interfaceChanged(row, notificationType) <--- Certainly passed as a pointer, but which address this pointer points to as row is never declared?????
}
.../...
virtual void interfaceChanged(
PMIB_IPINTERFACE_ROW row, <--------- same row coming from nowhere
MIB_NOTIFICATION_TYPE notificationType)
{
const char* family = "Unknown";
if (row) {
//Is row is not NULL?
family = getFamily(row->Family); <--------- the -> syntax confirms the pointer type

Quote:3. Use as pointer. Or replace MIB_IPINTERFACE_ROW*Row to MIB_IPINTERFACE_ROW&Row and use as reference. When accessing members, in QM it is the same in both cases: Row.member.

Indeed from upper code, it is a pointer. But as a pointer, it must be pointing to a memory address to be usable, as reference, it must exist....

But my code fails on row.family statement, because it seems an invalid pointer, as it is not initialized, giving then invalid pointer error at execution.

In my QM code, row variable is not filled by the callback function it seems to be the best hypothesis.

Maybe i must use v command as it is coded in a sub function, maybe something else, will try later after work....

thanks for you patiente and time anyway, i'm sure i'll get it working with your support


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)