Reputation: 2877
This question is a follow up on: Redefinition and Enumerator
My C++ compiler gives the following warning and error:
1>forgelib\source\socket.cpp(145): warning C4832: token '.' is illegal after UDT 'Forge::AddressFamily'
1> forgelib\include\forge\socket.h(70) : see declaration of 'Forge::AddressFamily'
1>forgelib\source\socket.cpp(145): error C2275: 'Forge::AddressFamily' : illegal use of this type as an expression
1> forgelib\include\forge\socket.h(70) : see declaration of 'Forge::AddressFamily'
1>forgelib\source\socket.cpp(145): error C2228: left of '.INet' must have class/struct/union
This is socket.cpp(145):
void Forge::InternetHost::validHostEntity(hostent* he) {
if (he->h_addrtype != AddressFamily.INet || he->h_length != 4) { // <--145
throw new Forge::SocketException("Address family mismatch.");
}
}
This is the definition:
struct AddressFamily {
static const Forge::Int Unspecified = AF_UNSPEC;
static const Forge::Int UNIX = AF_UNIX;
static const Forge::Int INet = AF_INET;
static const Forge::Int IPX = AF_IPX;
static const Forge::Int AppleTalk = AF_APPLETALK;
static const Forge::Int INet6 = AF_INET6;
};
Am I missing something here that's really obvious?
Upvotes: 0
Views: 101
Reputation: 412
You should try like this to access the static member:
AddressFamily::INet
Upvotes: 2
Reputation: 55887
Should be
he->h_addrtype != AddressFamily::INet
since INet
is a static member of struct.
Upvotes: 2
Reputation: 227390
INet
is a static member of AddressFamily
so you need
AddressFamily::INet
Upvotes: 2