In my project there are some compilation error C2872
due to ambiguous definition of byte
, after I set -Include
, the output shows that C2872
is due to the in included file:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\comdef.h
from one of my myado.h
file.
However, this is no such include anywhere in myado.h
, how come it is included?
myado.h
did something like this:
#import "C:/Program Files/Common Files/System/ado/msado15.dll" rename("EOF", "adoEOF") rename("BOF", "adoBOF")
#include <icrsint.h> // ADO C/C++ Record Binding Definitions
#define TESTHR(x) if FAILED(x) _com_issue_error(x)
, here FAILED
is a macro defined in
c:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\shared\winerror.h
and _com_issue_error
is defined in
c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\comutil.h
is this the reason?
But if this is the case, how were the header files got included, due to the marco usage?
Or, how was c++ compiler visual studio recognize the macro definition?
all credit goes to Ken White.
After compilation, due to #import "C:/Program Files/Common Files/System/ado/msado15.dll" rename("EOF", "adoEOF") rename("BOF", "adoBOF")
, a msado15.tlh
will be generated under project's Debug
folder, which starts as:
// Created by Microsoft (R) C/C++ Compiler Version 14.12.25830.2 (dbe79e7e).
//
// c:\c20180411hp_cpp17_01\debug\msado15.tlh
//
// C++ source equivalent of type library C:/Program Files/Common Files/System/ado/msado15.dll
// compiler-generated file created 06/20/18 at 15:50:36 - DO NOT EDIT!
#pragma once
#pragma pack(push, 8)
#include <comdef.h>
, voila!