[C API] Fix the BOOLEAN in ov_element_type conflict with the typedefine in Windows.h (#19380)

* [C API] Fix BOOLEAN confict between Windows.h & ov_element_type_e in OV

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [C API] fix clang format

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [C API] Add test for BOOLEAN conflict

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [C API] fix clang format

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [C API] Fix warning & comments

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [C API] enable OV_BOOLEAN for windows & linux

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [C API] fix build error

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [C API] Remove WIN_BOOLEAN

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* Update ov_windows_conflict_test.cpp

---------

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
This commit is contained in:
Xuejun Zhai 2023-09-26 22:21:50 +08:00 committed by GitHub
parent 5384fe43df
commit 845bbfc9c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -15,6 +15,12 @@
**/ **/
#pragma once #pragma once
#ifdef _WINDOWS_
# pragma message( \
"The BOOLEAN define in ov_element_type_e conflict with Windows.h BOOLEAN define. The BOOLEAN of ov_element_type_e redefine to OV_BOOLEAN here. If you want to use BOOLEAN of Windows.h, pls redefine befor include openvino/c/openvino.h, such as typedef BOOLEAN WIN_BOOLEAN")
#endif
#define BOOLEAN OV_BOOLEAN
#include "openvino/c/auto/properties.h" #include "openvino/c/auto/properties.h"
#include "openvino/c/ov_common.h" #include "openvino/c/ov_common.h"
#include "openvino/c/ov_compiled_model.h" #include "openvino/c/ov_compiled_model.h"

View File

@ -0,0 +1,26 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/*
* This test only for Windows, which caused by the BOOLEAN define conflict between Windows.h and openvino.h
* (ov_element_type_e). Sollution: 1) check Windows.h was used or not in openvino.h for windows OS 2) if YES, will
* redefine the "BOOLEAN" from Windows.h to "WIN_BOOLEAN" and also redefine the "BOOLEAN" from openvino.h to
* "OV_BOOLEAN"
*/
#if defined(_WIN32)
# include <gtest/gtest.h>
# include <windows.h>
# include "openvino/c/openvino.h"
# ifndef UNUSED
# define UNUSED(x) ((void)(x))
# endif
TEST(ov_windows_conflict_test, ov_windows_boolean_conflict) {
ov_element_type_e element_type = OV_BOOLEAN; // The BOOLEAN from ov_element_type_e will be replaced by OV_BOOLEAN
UNUSED(element_type);
}
#endif