Why can I link functions in the GFLW dynamic link library when this function is not modified with __declspec(dllexport)?

冬天配地瓜 0 Reputation points
2024-03-24T10:37:27.9466667+00:00

I added a preprocessor in visual studio, that is, #define GLFWAPI, and then when I ran my program, I found that the program was able to link to the function GLFWAPI int glfwGetKeyScancode(int key). I learned from the official website that any other functions in the DLL are private functions of the DLL, but I clearly did not define GLFWAPI as __declspec(dllexport), that is, #define GLFWAPI __declspec(dllexport). Why can my program still link the glfwGetKeyScancode function?

Developer technologies | C++
{count} votes

1 answer

Sort by: Most helpful
  1. RLWA32 49,551 Reputation points
    2024-03-24T11:16:08.62+00:00

    There are various ways to export functions from a dll and __declspec(dllexport) is only one of them. For example, functions can be exported using module definition files containing the EXPORTS statement. See Exporting from a DLL Using DEF Files


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.