Errors referencing SetPortA

Linker errors on Windows

Info & Tags

Article #:
256
Created:
12/15/06
Modified:
09/19/08
Tags:
error, linker, setporta, windows

PROBLEM

Why do I get an error referencing SetPortA when calling ClientApi::SetPort?


SOLUTION

The following linker error on  Windows:

"error LNK2019: unresolved external symbol "public: void __thiscall

ClientApi::SetPortA(char const *)"
is due to a defined macro within winspool.h, which is included by windows.h.

winspool.h defines the macro SetPort to be SetPortA. The preprocessor sees the reference to client::SetPort and replaces it with client::SetPortA, causing the linker to error.

To resolve this issue, insert "#undef SetPort" immediately after your inclusion of windows.h within your programs.