Skip to content

Commit

Permalink
Merge pull request #4218 from facebook/externC
Browse files Browse the repository at this point in the history
Move #includes out of `extern "C"` blocks
  • Loading branch information
Victor-C-Zhang authored Jan 7, 2025
2 parents f5e2996 + 8f49db5 commit a610550
Show file tree
Hide file tree
Showing 37 changed files with 157 additions and 304 deletions.
2 changes: 0 additions & 2 deletions contrib/pzstd/test/PzstdTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
* in the COPYING file in the root directory of this source tree).
*/
#include "Pzstd.h"
extern "C" {
#include "datagen.h"
}
#include "test/RoundTrip.h"
#include "utils/ScopeGuard.h"

Expand Down
2 changes: 0 additions & 2 deletions contrib/pzstd/test/RoundTripTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
*/
extern "C" {
#include "datagen.h"
}
#include "Options.h"
#include "test/RoundTrip.h"
#include "utils/ScopeGuard.h"
Expand Down
6 changes: 3 additions & 3 deletions contrib/seekable_format/zstd_seekable.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef SEEKABLE_H
#define SEEKABLE_H

#include <stdio.h>
#include "zstd.h" /* ZSTDLIB_API */

#if defined (__cplusplus)
extern "C" {
#endif

#include <stdio.h>
#include "zstd.h" /* ZSTDLIB_API */


#define ZSTD_seekTableFooterSize 9

Expand Down
8 changes: 0 additions & 8 deletions lib/common/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#ifndef BITSTREAM_H_MODULE
#define BITSTREAM_H_MODULE

#if defined (__cplusplus)
extern "C" {
#endif
/*
* This API consists of small unitary functions, which must be inlined for best performance.
* Since link-time-optimization is not available for all compilers,
Expand All @@ -32,7 +29,6 @@ extern "C" {
#include "error_private.h" /* error codes and messages */
#include "bits.h" /* ZSTD_highbit32 */


/*=========================================
* Target specific
=========================================*/
Expand Down Expand Up @@ -450,8 +446,4 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
}

#if defined (__cplusplus)
}
#endif

#endif /* BITSTREAM_H_MODULE */
9 changes: 0 additions & 9 deletions lib/common/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
#ifndef DEBUG_H_12987983217
#define DEBUG_H_12987983217

#if defined (__cplusplus)
extern "C" {
#endif


/* static assert is triggered at compile time, leaving no runtime artefact.
* static assert only works with compile-time constants.
Expand Down Expand Up @@ -108,9 +104,4 @@ extern int g_debuglevel; /* the variable is only declared,
# define DEBUGLOG(l, ...) do { } while (0) /* disabled */
#endif


#if defined (__cplusplus)
}
#endif

#endif /* DEBUG_H_12987983217 */
10 changes: 0 additions & 10 deletions lib/common/error_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
#ifndef ERROR_H_MODULE
#define ERROR_H_MODULE

#if defined (__cplusplus)
extern "C" {
#endif


/* ****************************************
* Dependencies
******************************************/
Expand All @@ -26,7 +21,6 @@ extern "C" {
#include "debug.h"
#include "zstd_deps.h" /* size_t */


/* ****************************************
* Compiler-specific
******************************************/
Expand Down Expand Up @@ -161,8 +155,4 @@ void _force_has_format_string(const char *format, ...) {
} \
} while(0)

#if defined (__cplusplus)
}
#endif

#endif /* ERROR_H_MODULE */
15 changes: 0 additions & 15 deletions lib/common/fse.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
****************************************************************** */

#if defined (__cplusplus)
extern "C" {
#endif

#ifndef FSE_H
#define FSE_H

Expand All @@ -25,7 +20,6 @@ extern "C" {
******************************************/
#include "zstd_deps.h" /* size_t, ptrdiff_t */


/*-*****************************************
* FSE_PUBLIC_API : control library symbols visibility
******************************************/
Expand Down Expand Up @@ -232,11 +226,8 @@ If there is an error, the function will return an error code, which can be teste

#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY)
#define FSE_H_FSE_STATIC_LINKING_ONLY

/* *** Dependency *** */
#include "bitstream.h"


/* *****************************************
* Static allocation
*******************************************/
Expand Down Expand Up @@ -631,10 +622,4 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr)

#define FSE_TABLESTEP(tableSize) (((tableSize)>>1) + ((tableSize)>>3) + 3)


#endif /* FSE_STATIC_LINKING_ONLY */


#if defined (__cplusplus)
}
#endif
9 changes: 0 additions & 9 deletions lib/common/huf.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
* You may select, at your option, one of the above-listed licenses.
****************************************************************** */

#if defined (__cplusplus)
extern "C" {
#endif

#ifndef HUF_H_298734234
#define HUF_H_298734234

Expand All @@ -25,7 +21,6 @@ extern "C" {
#define FSE_STATIC_LINKING_ONLY
#include "fse.h"


/* *** Tool functions *** */
#define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */
size_t HUF_compressBound(size_t size); /**< maximum compressed size (worst case) */
Expand Down Expand Up @@ -280,7 +275,3 @@ size_t HUF_readDTableX2_wksp(HUF_DTable* DTable, const void* src, size_t srcSize
#endif

#endif /* HUF_H_298734234 */

#if defined (__cplusplus)
}
#endif
10 changes: 0 additions & 10 deletions lib/common/mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#ifndef MEM_H_MODULE
#define MEM_H_MODULE

#if defined (__cplusplus)
extern "C" {
#endif

/*-****************************************
* Dependencies
******************************************/
Expand Down Expand Up @@ -76,7 +72,6 @@ extern "C" {
typedef signed long long S64;
#endif


/*-**************************************************************
* Memory I/O API
*****************************************************************/
Expand Down Expand Up @@ -424,9 +419,4 @@ MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val)
/* code only tested on 32 and 64 bits systems */
MEM_STATIC void MEM_check(void) { DEBUG_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); }


#if defined (__cplusplus)
}
#endif

#endif /* MEM_H_MODULE */
9 changes: 0 additions & 9 deletions lib/common/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#ifndef POOL_H
#define POOL_H

#if defined (__cplusplus)
extern "C" {
#endif


#include "zstd_deps.h"
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_customMem */
Expand Down Expand Up @@ -82,9 +78,4 @@ void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque);
*/
int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque);


#if defined (__cplusplus)
}
#endif

#endif
8 changes: 0 additions & 8 deletions lib/common/threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

#include "debug.h"

#if defined (__cplusplus)
extern "C" {
#endif

#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)

/**
Expand Down Expand Up @@ -72,7 +68,6 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread);
* add here more wrappers as required
*/


#elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */
/* === POSIX Systems === */
# include <pthread.h>
Expand Down Expand Up @@ -143,8 +138,5 @@ typedef int ZSTD_pthread_cond_t;

#endif /* ZSTD_MULTITHREAD */

#if defined (__cplusplus)
}
#endif

#endif /* THREADING_H_938743 */
Loading

0 comments on commit a610550

Please sign in to comment.