0

How can trying to build a COM in Visual studio2015 with the following code.
MIDL: error MIDL2337: unsatisfied forward declaration: _Bool
Error of me will fail out.

import "oaidl.idl";
import "ocidl.idl";


#include <stdbool.h>
#include <time.h>

[uuid("B60DAB85-864C-4C5F-82BF-414AE59B1F1F"), object]
interface ISampleCOM : IUnknown
{
    [propget,
        helpstring("Get NowTime.")] HRESULT GetNowTime(
            [out, retval] time_t* ReturnVal);

}

[uuid("F2544169-985E-4F49-99AD-D51D8C93F5C4")]
coclass SampleCOM
{
    interface ISampleCOM;
}

Do you have any good workaround?

tome119
  • 33
  • 6
  • You can't generally include C or C++ headers into IDL. MIDL is not a C compiler, it doesn't understand all C constructs. Drop the `#include`s, and use a `long` or `hyper` or similar in place of `time_t`. – Igor Tandetnik Nov 28 '15 at 04:54
  • C99 has been ignored too long to make `_Bool` a suitable interop type. The only one you can count on to be well supported by other language runtimes is `VARIANT_BOOL`. You also can't use `time_t`, it has Y2K38 disaster issues and its size is not guaranteed. Trickier to solve, consider `DATE`. – Hans Passant Nov 28 '15 at 12:22
  • thank you. Try doing the `time_t` to `long`. – tome119 Nov 30 '15 at 22:51

0 Answers0