使用makeword函数创建错误e0109-表观呼叫的括号前表达式必须具有(指针到 - )函数类型

using MAKEWORD function creates error E0109- expression preceding parentheses of apparent call must have (pointer-to-) function type

本文关键字:函数 类型 表达式 指针 e0109- 错误 创建 makeword 表观 呼叫 使用      更新时间:2023-10-16

我正在使用CPP,套接字,JSON和WINSOCK2编写一个项目来创建服务器和客户端之间的连接,我正在使用winsock2.h的函数WSASTARTUP来启动连接。我复制了从Internet代码中使用的方式,并且它持续了一段时间,直到突然sakeword函数创建了一个错误。

这是我在其中使用makeword的功能:(communicator,requestHandelerFactory和m_handlerFactory是我创建的类,忽略它(

Communicator::Communicator(RequestHandelerFactory* RHF) : m_handlerFactory(RHF)
{
    WSADATA wsa_data = {};
    if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != 0)
    {
        throw std::exception("wsa startup failed");
    }
    std::cout << "Starting..." << std::endl;
    _serverSocket = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (_serverSocket == INVALID_SOCKET)
    {
        throw std::exception(__FUNCTION__ " - socket");
    }
}

包括并定义了我使用的:

#pragma warning(disable : 4996)
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <stdio.h>
#include <sstream>
#include <bitset>
#include <exception>
#include <minwindef.h>
#include <windef.h>
#include <ctime>
//some more includes from code I wrote
#pragma comment (lib, "ws2_32.lib")

错误在makeword函数中出现,无论我做什么,它仍然给出相同的错误。

E0109 expression preceding parentheses of apparent call must have (pointer-to-) function type

我正在使用Visual Studio 2017,如果有任何更改。我尝试以许多方式解决该解决,似乎没有任何作用。

问题是在我的代码之前使用define。谢谢:(