Skip to content

Commit 10c5b12

Browse files
committed
[*.h] More careful header guards for MSVC ; [acquire/libacquire_export.h] Attempts to manually create export header to get "inconsistent dll linkage" error resolved
1 parent 6e1ca3c commit 10c5b12

18 files changed

+143
-62
lines changed

acquire/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ target_compile_definitions("${LIBRARY_NAME}" "${lib_vis}" "_${TARGET_ARCH}_")
350350
include(GenerateExportHeader)
351351
set(_export_file "${CMAKE_CURRENT_BINARY_DIR}/lib${LIBRARY_NAME}_export.h")
352352

353-
if (LIBACQUIRE_HEADER_ONLY)
353+
if (1)
354+
# pass
355+
elseif (LIBACQUIRE_HEADER_ONLY)
354356
file(WRITE "${_export_file}"
355357
"#ifndef LIBACQUIRE_EXPORT_H\n"
356358
"#define LIBACQUIRE_EXPORT_H\n\n"
@@ -404,5 +406,5 @@ install(TARGETS ${installable_libs}
404406
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
405407
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
406408
install(FILES "${PROJECT_BINARY_DIR}/src/acquire_config.h"
407-
${Header_Files} ${_Header_Files} ${_export_file}
409+
${Header_Files} ${_Header_Files} # ${_export_file}
408410
TYPE "INCLUDE")

acquire/acquire_download.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ extern "C" {
2828
#include "acquire_checksums.h"
2929
#include "libacquire_export.h"
3030

31-
#if defined(USE_COMMON_CRYPTO) || defined(USE_OPENSSL)
31+
#if (defined(USE_COMMON_CRYPTO) && USE_COMMON_CRYPTO==1) || (defined(USE_OPENSSL) && USE_OPENSSL==1)
3232
#include "acquire_openssl.h"
33-
#elif defined(USE_WINCRYPT)
33+
#elif defined(USE_WINCRYPT) && USE_WINCRYPT==1
3434
#include "acquire_wincrypt.h"
35-
#endif /* defined(USE_COMMON_CRYPTO) || defined(USE_OPENSSL) */
35+
#endif /* (defined(USE_COMMON_CRYPTO) && USE_COMMON_CRYPTO==1) || (defined(USE_OPENSSL) && USE_OPENSSL==1) */
3636

3737
extern LIBACQUIRE_EXPORT const char *get_download_dir(void);
3838

acquire/acquire_libarchive.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#if !defined(LIBACQUIRE_ACQUIRE_LIBARCHIVE_H) && defined(USE_LIBARCHIVE) && \
2-
defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_EXTRACT_IMPL)
1+
#if !defined(LIBACQUIRE_ACQUIRE_LIBARCHIVE_H) && defined(USE_LIBARCHIVE) && \
2+
USE_LIBARCHIVE==1 && defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_EXTRACT_IMPL)
33
#define LIBACQUIRE_ACQUIRE_LIBARCHIVE_H
44
#define LIBACQUIRE_EXTRACT_IMPL
55

@@ -111,6 +111,5 @@ int extract_archive(enum Archive archive, const char *archive_filepath,
111111
}
112112
#endif /* __cplusplus */
113113

114-
#endif /* !defined(LIBACQUIRE_ACQUIRE_LIBARCHIVE_H) && defined(USE_LIBARCHIVE) \
115-
&& defined(LIBACQUIRE_IMPLEMENTATION) && \
116-
!defined(LIBACQUIRE_EXTRACT_IMPL) */
114+
#endif /* !defined(LIBACQUIRE_ACQUIRE_LIBARCHIVE_H) && defined(USE_LIBARCHIVE) && \
115+
USE_LIBARCHIVE==1 && defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_EXTRACT_IMPL) */

acquire/acquire_libcurl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef LIBACQUIRE_LIBCURL_H
22
#define LIBACQUIRE_LIBCURL_H
33

4-
#if defined(USE_LIBCURL) && defined(LIBACQUIRE_IMPLEMENTATION)
4+
#if defined(USE_LIBCURL) && USE_LIBCURL==1 && defined(LIBACQUIRE_IMPLEMENTATION)
55

66
/*
77
* libcurl implementation of libacquire's download API

acquire/acquire_libfetch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ __FBSDID("$FreeBSD$");
7474
#include <termios.h>
7575
#include <unistd.h>
7676

77-
#ifdef USE_MY_LIBFETCH
77+
#if defined(USE_MY_LIBFETCH) && USE_MY_LIBFETCH==1
7878
#include "freebsd_libfetch/fetch.h"
7979
#else
8080
#include <fetch.h>
81-
#endif /* USE_MY_LIBFETCH */
81+
#endif /* defined(USE_MY_LIBFETCH) && USE_MY_LIBFETCH==1 */
8282

8383
#define TIMEOUT 120
8484

acquire/acquire_librhash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef LIBACQUIRE_ACQUIRE_LIBRHASH_H
66
#define LIBACQUIRE_ACQUIRE_LIBRHASH_H
77

8-
#if defined(LIBACQUIRE_IMPLEMENTATION) && defined(USE_LIBRHASH)
8+
#if defined(LIBACQUIRE_IMPLEMENTATION) && defined(USE_LIBRHASH) && USE_LIBRHASH==1
99

1010
#ifdef __cplusplus
1111
extern "C" {

acquire/acquire_miniz.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !defined(LIBACQUIRE_ACQUIRE_MINIZ_H) && defined(USE_MINIZ) && \
1+
#if !defined(LIBACQUIRE_ACQUIRE_MINIZ_H) && defined(USE_MINIZ) && USE_MINIZ==1 \
22
defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_EXTRACT_IMPL)
33
#define LIBACQUIRE_ACQUIRE_MINIZ_H
44
#define LIBACQUIRE_EXTRACT_IMPL
@@ -41,6 +41,5 @@ int extract_archive(enum Archive archive, const char *archive_filepath,
4141
}
4242
#endif /* __cplusplus */
4343

44-
#endif /* !defined(LIBACQUIRE_ACQUIRE_MINIZ_H) && defined(USE_MINIZ) && \
45-
defined(LIBACQUIRE_IMPLEMENTATION) && \
46-
!defined(LIBACQUIRE_EXTRACT_IMPL) */
44+
#endif /* !defined(LIBACQUIRE_ACQUIRE_MINIZ_H) && defined(USE_MINIZ) && USE_MINIZ==1 \
45+
defined(LIBACQUIRE_IMPLEMENTATION) && !defined(LIBACQUIRE_EXTRACT_IMPL) */

acquire/acquire_openssl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern "C" {
1717

1818
#include "acquire_config.h"
1919

20-
#if defined(USE_COMMON_CRYPTO) || defined(USE_OPENSSL)
20+
#if (defined(USE_COMMON_CRYPTO) && USE_COMMON_CRYPTO==1) || (defined(USE_OPENSSL) && USE_OPENSSL==1)
2121

2222
#include "acquire_checksums.h"
2323

@@ -37,7 +37,7 @@ extern "C" {
3737
#define SHA512_Final CC_SHA512_Final
3838
#define SHA512_BLOCK_BYTES CC_SHA512_BLOCK_BYTES
3939

40-
#elif defined(USE_OPENSSL)
40+
#elif defined(USE_OPENSSL) && USE_OPENSSL==1
4141

4242
#include <openssl/macros.h>
4343
#include <openssl/sha.h>
@@ -50,7 +50,7 @@ extern "C" {
5050
#define SHA256_BLOCK_BYTES 64 /* block size in bytes */
5151
#define SHA512_BLOCK_BYTES (SHA256_BLOCK_BYTES * 2)
5252

53-
#endif /* USE_COMMON_CRYPTO */
53+
#endif /* (defined(USE_COMMON_CRYPTO) && USE_COMMON_CRYPTO==1) || (defined(USE_OPENSSL) && USE_OPENSSL==1) */
5454

5555
#include <errno.h>
5656
#include <stdio.h>

acquire/acquire_wincrypt.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This should also work on Windows, ReactOS, and derivatives.
55
* */
66

7-
#if !defined(LIBACQUIRE_WINCRYPT_H) && defined(USE_WINCRYPT) && \
7+
#if !defined(LIBACQUIRE_WINCRYPT_H) && defined(USE_WINCRYPT) && USE_WINCRYPT==1 \
88
defined(LIBACQUIRE_IMPLEMENTATION) && defined(LIBACQUIRE_CRYPTO_IMPL)
99
#define LIBACQUIRE_WINCRYPT_H
1010

@@ -145,6 +145,5 @@ bool sha512(const char *filename, const char *hash) {
145145
}
146146
#endif /* __cplusplus */
147147

148-
#endif /* !defined(LIBACQUIRE_WINCRYPT_H) && defined(USE_WINCRYPT) && \
149-
defined(LIBACQUIRE_IMPLEMENTATION) && \
150-
defined(LIBACQUIRE_CRYPTO_IMPL) */
148+
#endif /* !defined(LIBACQUIRE_WINCRYPT_H) && defined(USE_WINCRYPT) && USE_WINCRYPT==1 \
149+
defined(LIBACQUIRE_IMPLEMENTATION) && defined(LIBACQUIRE_CRYPTO_IMPL) */

acquire/acquire_wininet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* */
66

77
#if !defined(LIBACQUIRE_WININET_H) && defined(USE_WININET) && \
8-
defined(LIBACQUIRE_IMPLEMENTATION)
8+
USE_WININET==1 && defined(LIBACQUIRE_IMPLEMENTATION)
99
#define LIBACQUIRE_WININET_H
1010

1111
#ifdef __cplusplus
@@ -134,5 +134,5 @@ int download(const char *url, enum Checksum checksum, const char *hash,
134134
}
135135
#endif /* __cplusplus */
136136

137-
#endif /* !defined(LIBACQUIRE_WININET_H) && defined(USE_WININET) && \
138-
defined(LIBACQUIRE_IMPLEMENTATION) */
137+
#endif /* !defined(LIBACQUIRE_WININET_H) && defined(USE_WININET) && \
138+
USE_WININET==1 && defined(LIBACQUIRE_IMPLEMENTATION) */

0 commit comments

Comments
 (0)