Skip to content

Commit

Permalink
Regards mpaland#77: MISRA-C++:2008 Rule 18-0-1: The C library shall n…
Browse files Browse the repository at this point in the history
…ot be used. ... so, when printf is used in C++, we use the C++-version of the C library headers.
  • Loading branch information
sander.hagendoorn authored and eyalroz committed Feb 21, 2022
1 parent 2d8d23d commit 944d240
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/printf/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@
* THE SOFTWARE.
*/

#ifdef __cplusplus
#include <cstdint>
extern "C" {
#else
#include <stdbool.h>
#include <stdint.h>
#endif

// Define this globally (e.g. gcc -DPRINTF_INCLUDE_CONFIG_H ...) to include the
// printf_config.h header file
Expand Down Expand Up @@ -1176,3 +1181,6 @@ int vfctprintf(void (*out)(char character, void* arg), void* arg, const char* fo
return _vsnprintf(out_wrapped_function, (char*)(uintptr_t)&out_fct_wrap, (size_t)-1, format, va);
}

#ifdef __cplusplus
} // extern "C"
#endif
11 changes: 6 additions & 5 deletions src/printf/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@
#ifndef PRINTF_H_
#define PRINTF_H_

#include <stdarg.h>
#include <stddef.h>


#ifdef __cplusplus
# include <cstdarg>
# include <cstddef>
extern "C" {
#else
# include <stdarg.h>
# include <stddef.h>
#endif

#ifdef __GNUC__
Expand Down Expand Up @@ -136,7 +137,7 @@ int fctprintf(void (*out)(char character, void* arg), void* arg, const char* for
int vfctprintf(void (*out)(char character, void* arg), void* arg, const char* format, va_list va) ATTR_VPRINTF(3);

#ifdef __cplusplus
}
} // extern "C"
#endif

#if PRINTF_ALIAS_STANDARD_FUNCTION_NAMES
Expand Down

0 comments on commit 944d240

Please sign in to comment.