I have C++ code in Visual Studio that calls some functions from the Windows API. This code is shared and I don't want to change it much, but I want to provide error logging if some Windows function returns an error. My plan was to define alternatives to all Windows functions in a separate source file in some namespace WinLog
, and force the shared code to call my functions instead of the Windows API functions. All of the shared code includes the stdafx.h
header, and if I add these lines in that header:
#include "WinLog.h"
using namespace WinLog;
then the shared code would call my functions. I don't care about using namespace
in header files. But the problem is that, now the compiler reports compilation errors, for instance:
C2668: 'SCardReleaseContext': ambiguous call to overloaded function
How can I make the shared code call my functions if I only change something in stdafx.h
?