From 27340559e6a09df18b692084cef8ad76e3541d0c Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Wed, 27 Nov 2024 06:16:00 +0200 Subject: [PATCH] Test all three custom host headers --- src/native/corehost/coreclr_delegates.h | 16 +++++++++++++--- src/native/corehost/nethost/nethost.h | 13 +++++++------ .../corehost/test/mockhostfxr/test_c_api.c | 12 +++++++----- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/native/corehost/coreclr_delegates.h b/src/native/corehost/coreclr_delegates.h index 550badf135097b..1a175803e0aba9 100644 --- a/src/native/corehost/coreclr_delegates.h +++ b/src/native/corehost/coreclr_delegates.h @@ -1,11 +1,17 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef __CORECLR_DELEGATES_H__ -#define __CORECLR_DELEGATES_H__ +#ifndef HAVE_CORECLR_DELEGATES_H +#define HAVE_CORECLR_DELEGATES_H +#include #include +#ifdef __cplusplus +extern "C" +{ +#endif + #if defined(_WIN32) #define CORECLR_DELEGATE_CALLTYPE __stdcall #ifdef _WCHAR_T_DEFINED @@ -57,4 +63,8 @@ typedef int (CORECLR_DELEGATE_CALLTYPE *load_assembly_bytes_fn)( void *load_context /* Extensibility parameter (currently unused and must be 0) */, void *reserved /* Extensibility parameter (currently unused and must be 0) */); -#endif // __CORECLR_DELEGATES_H__ +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // HAVE_CORECLR_DELEGATES_H diff --git a/src/native/corehost/nethost/nethost.h b/src/native/corehost/nethost/nethost.h index eaca17535e7676..ef420e81bdc2d7 100644 --- a/src/native/corehost/nethost/nethost.h +++ b/src/native/corehost/nethost/nethost.h @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef __NETHOST_H__ -#define __NETHOST_H__ +#ifndef HAVE_NETHOST_H +#define HAVE_NETHOST_H #include @@ -37,7 +37,8 @@ #endif #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // Parameters for get_hostfxr_path @@ -93,7 +94,7 @@ NETHOST_API int NETHOST_CALLTYPE get_hostfxr_path( const struct get_hostfxr_parameters *parameters); #ifdef __cplusplus -} // extern "C" -#endif +} +#endif // __cplusplus -#endif // __NETHOST_H__ +#endif // HAVE_NETHOST_H diff --git a/src/native/corehost/test/mockhostfxr/test_c_api.c b/src/native/corehost/test/mockhostfxr/test_c_api.c index 3307b96162a7a2..c9c3a23fec6d1e 100644 --- a/src/native/corehost/test/mockhostfxr/test_c_api.c +++ b/src/native/corehost/test/mockhostfxr/test_c_api.c @@ -1,8 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// hostfxr.h is a public API. When included in .c files, it may fail to compile -// if C++-specific syntax is used within the extern "C" block. Since all usage of -// this API in runtime repo is within C++ code, such breakages are not encountered -// during normal development or testing. -#include "hostfxr.h" +// These headers provide access to the public hosting APIs. This file tests that +// they can be included in pure C code without causing compilation errors. +// Since the runtime repository primarily uses these APIs in C++ code, such issues +// might not be caught during regular development or testing. +#include +#include +#include