Skip to content

Commit

Permalink
headers: add c++ linkage support
Browse files Browse the repository at this point in the history
  • Loading branch information
joelguittet committed Feb 17, 2023
1 parent f9acf15 commit ae627eb
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check_include_guards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ result=""
for source_file in `git ls-tree -r HEAD --name-only | grep -E '(.*\.h$|.*\.hpp$)' | grep -vFf .clang-format-ignore`
do
uppercase=$(echo $(basename ${source_file^^}) | tr '.' '_' | tr '-' '_')
pcregrep -Me "#ifndef __${uppercase}__\n#define __${uppercase}__" ${source_file} > /dev/null 2>&1
pcregrep -Me "#ifndef __${uppercase}__\n#define __${uppercase}__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif" ${source_file} > /dev/null 2>&1
if [[ ! $? -eq 0 ]]; then
result="${result}\n${source_file}"
else
pcregrep -Me "#endif /\* __${uppercase}__ \*/" ${source_file} > /dev/null 2>&1
pcregrep -Me "#ifdef __cplusplus\n}\n#endif\n\n#endif /\* __${uppercase}__ \*/" ${source_file} > /dev/null 2>&1
if [[ ! $? -eq 0 ]]; then
result="${result}\n${source_file}"
fi
Expand Down
8 changes: 8 additions & 0 deletions include/mender-api.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_API_H__
#define __MENDER_API_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -107,4 +111,8 @@ mender_err_t mender_api_download_artifact(char *uri);
*/
mender_err_t mender_api_exit(void);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_API_H__ */
8 changes: 8 additions & 0 deletions include/mender-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_CLIENT_H__
#define __MENDER_CLIENT_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -83,4 +87,8 @@ mender_err_t mender_client_set_inventory(mender_inventory_t *inventory, size_t i
*/
mender_err_t mender_client_exit(void);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_CLIENT_H__ */
8 changes: 8 additions & 0 deletions include/mender-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_COMMON_H__
#define __MENDER_COMMON_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
Expand Down Expand Up @@ -65,4 +69,8 @@ typedef struct {
char *value; /**< Value of the item */
} mender_inventory_t;

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_COMMON_H__ */
8 changes: 8 additions & 0 deletions include/mender-http.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_HTTP_H__
#define __MENDER_HTTP_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -91,4 +95,8 @@ mender_err_t mender_http_perform(char * jwt,
*/
mender_err_t mender_http_exit(void);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_HTTP_H__ */
8 changes: 8 additions & 0 deletions include/mender-log.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_LOG_H__
#define __MENDER_LOG_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -97,4 +101,8 @@ mender_err_t mender_log_print(mender_log_level_t level, const char *filename, co
*/
mender_err_t mender_log_exit(void);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_LOG_H__ */
8 changes: 8 additions & 0 deletions include/mender-ota.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_OTA_H__
#define __MENDER_OTA_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -80,4 +84,8 @@ mender_err_t mender_ota_mark_app_valid_cancel_rollback(void);
*/
mender_err_t mender_ota_mark_app_invalid_rollback_and_reboot(void);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_OTA_H__ */
8 changes: 8 additions & 0 deletions include/mender-rtos.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_RTOS_H__
#define __MENDER_RTOS_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -84,4 +88,8 @@ void mender_rtos_semaphore_give(void *handle);
*/
void mender_rtos_semaphore_delete(void *handle);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_RTOS_H__ */
8 changes: 8 additions & 0 deletions include/mender-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_STORAGE_H__
#define __MENDER_STORAGE_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -95,4 +99,8 @@ mender_err_t mender_storage_clear_ota_deployment(void);
*/
mender_err_t mender_storage_exit(void);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_STORAGE_H__ */
8 changes: 8 additions & 0 deletions include/mender-tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_TLS_H__
#define __MENDER_TLS_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -78,4 +82,8 @@ mender_err_t mender_tls_sign_payload(unsigned char *private_key, size_t private_
*/
mender_err_t mender_tls_exit(void);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_TLS_H__ */
8 changes: 8 additions & 0 deletions include/mender-untar.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_UNTAR_H__
#define __MENDER_UNTAR_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand Down Expand Up @@ -84,4 +88,8 @@ int mender_untar_parse(
*/
void mender_untar_release(mender_untar_ctx_t *ctx);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_UNTAR_H__ */
8 changes: 8 additions & 0 deletions include/mender-utils.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef __MENDER_UTILS_H__
#define __MENDER_UTILS_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "mender-common.h"

/**
Expand All @@ -44,4 +48,8 @@ char *mender_utils_http_status_to_string(int status);
*/
char *mender_utils_deployment_status_to_string(mender_deployment_status_t deployment_status);

#ifdef __cplusplus
}
#endif

#endif /* __MENDER_UTILS_H__ */

0 comments on commit ae627eb

Please sign in to comment.