Files
libcoap/include/coap3/libcoap.h
T
Jon Shallow ea01661faf Zephyr: Support C++ builds
Some of the Zephyr include files need to be C++, not C based. The 'extern "C"'
wrapper in include/coap3/coap.h means that all #include are treated as being C.

Remove 'extern "C"' wrapper from include/coap3/coap.h and add wrapper to
include files after #include and before any function / structure definitions.

Add in a C++ build test for CI.
2025-08-21 12:17:41 +01:00

101 lines
2.4 KiB
C

/*
* libcoap.h -- platform specific header file for CoAP stack
*
* Copyright (C) 2015 Carsten Schoenert <c.schoenert@t-online.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
/**
* @file libcoap.h
* @brief Platform specific header file for CoAP stack
*/
#ifndef COAP_LIBCOAP_H_
#define COAP_LIBCOAP_H_
/* The non posix embedded platforms like Contiki-NG, TinyOS, RIOT, ... don't have
* a POSIX compatible header structure so we have to slightly do some platform
* related things. Currently there is only Contiki-NG available so we check for a
* CONTIKI environment and do *not* include the POSIX related network stuff. If
* there are other platforms in future there need to be analogous environments.
*
* The CONTIKI variable is within the Contiki-NG build environment! */
#if defined(_WIN32)
#include <ws2tcpip.h>
#if !defined(__MINGW32__)
#pragma comment(lib,"Ws2_32.lib")
#ifndef _SSIZE_T_DECLARED
typedef SSIZE_T ssize_t;
#define _SSIZE_T_DECLARED
#endif
#ifndef _IN_PORT_T_DECLARED
typedef USHORT in_port_t;
#define _IN_PORT_T_DECLARED
#endif
#endif /* !defined(__MINGW32__) */
#elif !defined (CONTIKI) && !defined (WITH_LWIP) && !defined (RIOT_VERSION)
#include <netinet/in.h>
#include <sys/socket.h>
#endif /* ! CONTIKI && ! WITH_LWIP && ! RIOT_VERSION */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef COAP_STATIC_INLINE
# if defined(__cplusplus)
# define COAP_STATIC_INLINE inline
# else
# if defined(_MSC_VER)
# define COAP_STATIC_INLINE static __inline
# else
# define COAP_STATIC_INLINE static inline
# endif
# endif
#endif
#ifndef COAP_DEPRECATED
# if defined(_MSC_VER)
# define COAP_DEPRECATED __declspec(deprecated)
# else
# define COAP_DEPRECATED __attribute__ ((deprecated))
# endif
#endif
#ifndef COAP_UNUSED
# ifdef __GNUC__
# define COAP_UNUSED __attribute__((unused))
# else /* __GNUC__ */
# define COAP_UNUSED
# endif /* __GNUC__ */
#endif /* COAP_UNUSED */
#ifndef COAP_THREAD_LOCAL_VAR
# ifdef __GNUC__
# define COAP_THREAD_LOCAL_VAR __thread
# elif defined(_MSC_VER)
# define COAP_THREAD_LOCAL_VAR __declspec(thread)
# else /* ! __GNUC__ && ! _MSC_VER */
# define COAP_THREAD_LOCAL_VAR
# endif
#endif
#ifndef COAP_API
#define COAP_API
#endif
void coap_startup(void);
void coap_cleanup(void);
#ifdef __cplusplus
}
#endif
#endif /* COAP_LIBCOAP_H_ */