From 2f750263c5791c7ff5b92a672764e419f5c9b97b Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Mon, 15 Nov 2021 14:22:16 -0700 Subject: [PATCH 01/21] build: export targets info --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7018903c..97a025ef8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,6 +158,9 @@ if(CMARK_SHARED OR CMARK_STATIC) ) install(EXPORT cmark-gfm DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) + + set(CMARK_TARGETS_FILE ${CMAKE_CURRENT_BINARY_DIR}/cmarkTargets.cmake) + export(TARGETS ${CMARK_INSTALL} FILE ${CMARK_TARGETS_FILE}) endif() # Feature tests From f2139c271fa5474a47a93f95a6993cf0b3446966 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Tue, 8 Mar 2022 16:38:22 -0700 Subject: [PATCH 02/21] link to pthreads on non-apple/non-windows --- src/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97a025ef8..d7b4f8f73 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -161,6 +161,16 @@ if(CMARK_SHARED OR CMARK_STATIC) set(CMARK_TARGETS_FILE ${CMAKE_CURRENT_BINARY_DIR}/cmarkTargets.cmake) export(TARGETS ${CMARK_INSTALL} FILE ${CMARK_TARGETS_FILE}) + + if(CMARK_THREADING AND NOT APPLE AND NOT MSVC) + if(CMARK_SHARED) + target_link_libraries(${LIBRARY} pthread) + endif(CMARK_SHARED) + + if(CMARK_STATIC) + target_link_libraries(${STATICLIBRARY} pthread) + endif(CMARK_STATIC) + endif() endif() # Feature tests From 78b85b7d89af1b167cbf60a85a995e4582c669f8 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 11 Mar 2022 14:37:19 -0700 Subject: [PATCH 03/21] use CMake-generated config.h if available --- src/include/cmark-gfm_config.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/include/cmark-gfm_config.h b/src/include/cmark-gfm_config.h index 1f96cc558..2905e964f 100644 --- a/src/include/cmark-gfm_config.h +++ b/src/include/cmark-gfm_config.h @@ -1,3 +1,7 @@ +#if __has_include("config.h") +#include "config.h" +#else + #ifndef CMARK_CONFIG_H #define CMARK_CONFIG_H @@ -75,4 +79,6 @@ CMARK_INLINE int c99_snprintf(char *outBuf, size_t size, const char *format, ... } #endif -#endif +#endif /* CMARK_CONFIG_H */ + +#endif /* config.h */ From 4347ac2fb9c4bd3590b3a3fdea5f4d01bc9c0a9b Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 11 Mar 2022 14:39:04 -0700 Subject: [PATCH 04/21] tweak static export header definitions --- .../include/cmark-gfm-extensions_export.h | 38 +++++++++++++------ src/include/cmark-gfm_export.h | 12 +++--- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/extensions/include/cmark-gfm-extensions_export.h b/extensions/include/cmark-gfm-extensions_export.h index 69c0bd787..b2c8e10f1 100644 --- a/extensions/include/cmark-gfm-extensions_export.h +++ b/extensions/include/cmark-gfm-extensions_export.h @@ -6,23 +6,39 @@ # define CMARK_GFM_EXTENSIONS_EXPORT # define CMARK_GFM_EXTENSIONS_NO_EXPORT #else -# ifndef CMARK_GFM_EXTENSIONS_EXPORT -# ifdef libcmark_gfm_extensions_EXPORTS - /* We are building this library */ -# define CMARK_GFM_EXTENSIONS_EXPORT __attribute__((visibility("default"))) -# else - /* We are using this library */ -# define CMARK_GFM_EXTENSIONS_EXPORT __attribute__((visibility("default"))) +# if defined(_WIN32) +# ifndef CMARK_GFM_EXTENSIONS_EXPORT +# ifdef libcmark_gfm_extensions_EXPORTS +# define CMARK_GFM_EXTENSIONS_EXPORT __declspec(dllexport) +# else +# define CMARK_GFM_EXTENSIONS_EXPORT __declspec(dllimport) +# endif +# endif + +# ifndef CMARK_GFM_EXTENSIONS_NO_EXPORT +# define CMARK_GFM_EXTENSIONS_NO_EXPORT +# endif +# else +# ifndef CMARK_GFM_EXTENSIONS_EXPORT +# ifdef libcmark_gfm_extensions_EXPORTS +# define CMARK_GFM_EXTENSIONS_EXPORT __attribute__((visibility("default"))) +# else +# define CMARK_GFM_EXTENSIONS_EXPORT __attribute__((visibility("default"))) +# endif # endif -# endif -# ifndef CMARK_GFM_EXTENSIONS_NO_EXPORT -# define CMARK_GFM_EXTENSIONS_NO_EXPORT __attribute__((visibility("hidden"))) +# ifndef CMARK_GFM_EXTENSIONS_NO_EXPORT +# define CMARK_GFM_EXTENSIONS_NO_EXPORT __attribute__((visibility("hidden"))) +# endif # endif #endif #ifndef CMARK_GFM_EXTENSIONS_DEPRECATED -# define CMARK_GFM_EXTENSIONS_DEPRECATED __attribute__ ((__deprecated__)) +# if !defined(_WIN32) +# define CMARK_GFM_EXTENSIONS_DEPRECATED __attribute__ ((__deprecated__)) +# else +# define CMARK_GFM_EXTENSIONS_DEPRECATED +# endif #endif #ifndef CMARK_GFM_EXTENSIONS_DEPRECATED_EXPORT diff --git a/src/include/cmark-gfm_export.h b/src/include/cmark-gfm_export.h index 7247214be..327cbf1d5 100644 --- a/src/include/cmark-gfm_export.h +++ b/src/include/cmark-gfm_export.h @@ -15,11 +15,7 @@ # define CMARK_GFM_NO_EXPORT # else # if defined(libcmark_gfm_EXPORTS) -# if defined(__linux__) -# define CMARK_GFM_EXPORT __attribute__((__visibility__("protected"))) -# else -# define CMARK_GFM_EXPORT __attribute__((__visibility__("default"))) -# endif +# define CMARK_GFM_EXPORT __attribute__((__visibility__("default"))) # else # define CMARK_GFM_EXPORT __attribute__((__visibility__("default"))) # endif @@ -28,7 +24,11 @@ #endif #ifndef CMARK_GFM_DEPRECATED -# define CMARK_GFM_DEPRECATED __attribute__ ((__deprecated__)) +# if !defined(_WIN32) +# define CMARK_GFM_DEPRECATED __attribute__ ((__deprecated__)) +# else +# define CMARK_GFM_DEPRECATED +# endif #endif #ifndef CMARK_GFM_DEPRECATED_EXPORT From 06c298ac4ea991e8eab97b8eebb6722f036f38d8 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 11 Mar 2022 14:41:50 -0700 Subject: [PATCH 05/21] don't use /include on generated-header include paths --- api_test/CMakeLists.txt | 4 ++-- extensions/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt index 2ae27d762..056fc2da8 100644 --- a/api_test/CMakeLists.txt +++ b/api_test/CMakeLists.txt @@ -6,9 +6,9 @@ add_executable(api_test ) include_directories( ${PROJECT_SOURCE_DIR}/src/include - ${PROJECT_BINARY_DIR}/src/include + ${PROJECT_BINARY_DIR}/src ${PROJECT_SOURCE_DIR}/extensions/include - ${PROJECT_BINARY_DIR}/extensions/include + ${PROJECT_BINARY_DIR}/extensions ) if(CMARK_SHARED) target_link_libraries(api_test libcmark-gfm-extensions libcmark-gfm) diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 4977c98c3..8a2b47986 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -15,7 +15,7 @@ set(LIBRARY_SOURCES include_directories( ${PROJECT_SOURCE_DIR}/src/include - ${PROJECT_BINARY_DIR}/src/include + ${PROJECT_BINARY_DIR}/src ) include (GenerateExportHeader) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7018903c..7fa60298f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,7 +45,7 @@ set(PROGRAM_SOURCES "${PROJECT_SOURCE_DIR}/bin/main.c") include_directories(include ${CMAKE_CURRENT_BINARY_DIR}) include_directories( ${PROJECT_SOURCE_DIR}/extensions/include - ${PROJECT_BINARY_DIR}/extensions/include + ${PROJECT_BINARY_DIR}/extensions ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark-gfm_version.h.in From f7b7b91792d4c3d7dd91142944dcc218f5730f4d Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 11 Mar 2022 14:44:04 -0700 Subject: [PATCH 06/21] remove unused section from static export headers --- extensions/include/cmark-gfm-extensions_export.h | 6 ------ src/include/cmark-gfm_export.h | 6 ------ 2 files changed, 12 deletions(-) diff --git a/extensions/include/cmark-gfm-extensions_export.h b/extensions/include/cmark-gfm-extensions_export.h index b2c8e10f1..fe32014cd 100644 --- a/extensions/include/cmark-gfm-extensions_export.h +++ b/extensions/include/cmark-gfm-extensions_export.h @@ -49,10 +49,4 @@ # define CMARK_GFM_EXTENSIONS_DEPRECATED_NO_EXPORT CMARK_GFM_EXTENSIONS_NO_EXPORT CMARK_GFM_EXTENSIONS_DEPRECATED #endif -#if 0 /* DEFINE_NO_DEPRECATED */ -# ifndef CMARK_GFM_EXTENSIONS_NO_DEPRECATED -# define CMARK_GFM_EXTENSIONS_NO_DEPRECATED -# endif -#endif - #endif /* CMARK_GFM_EXTENSIONS_EXPORT_H */ diff --git a/src/include/cmark-gfm_export.h b/src/include/cmark-gfm_export.h index 327cbf1d5..95e5da6d6 100644 --- a/src/include/cmark-gfm_export.h +++ b/src/include/cmark-gfm_export.h @@ -39,10 +39,4 @@ # define CMARK_GFM_DEPRECATED_NO_EXPORT CMARK_GFM_NO_EXPORT CMARK_GFM_DEPRECATED #endif -#if 0 /* DEFINE_NO_DEPRECATED */ -# ifndef CMARK_GFM_NO_DEPRECATED -# define CMARK_GFM_NO_DEPRECATED -# endif -#endif - #endif /* CMARK_GFM_EXPORT_H */ From 91cbac316ac3f2742bbb84ba9407a361e58a15aa Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 11 Mar 2022 14:45:47 -0700 Subject: [PATCH 07/21] clean up config headers - all the compilers we support have __has_include(), so use that instead of checking it in cmake - nothing in the library uses HAS__ATTRIBUTE__, so remove it --- src/CMakeLists.txt | 5 ----- src/config.h.in | 12 +----------- src/include/cmark-gfm_config.h | 12 +----------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7fa60298f..ffdb6ab88 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -165,14 +165,9 @@ include(CheckIncludeFile) include(CheckCSourceCompiles) include(CheckCSourceRuns) include(CheckSymbolExists) -CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H) CHECK_C_SOURCE_COMPILES( "int main() { __builtin_expect(0,0); return 0; }" HAVE___BUILTIN_EXPECT) -CHECK_C_SOURCE_COMPILES(" - int f(void) __attribute__ (()); - int main() { return 0; } -" HAVE___ATTRIBUTE__) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in diff --git a/src/config.h.in b/src/config.h.in index 65702b2e0..463a10a00 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -5,9 +5,7 @@ extern "C" { #endif -#cmakedefine HAVE_STDBOOL_H - -#ifdef HAVE_STDBOOL_H +#if __has_include() #include #elif !defined(__cplusplus) typedef char bool; @@ -15,16 +13,8 @@ extern "C" { #cmakedefine HAVE___BUILTIN_EXPECT -#cmakedefine HAVE___ATTRIBUTE__ - #cmakedefine CMARK_THREADING -#ifdef HAVE___ATTRIBUTE__ - #define CMARK_ATTRIBUTE(list) __attribute__ (list) -#else - #define CMARK_ATTRIBUTE(list) -#endif - #ifndef CMARK_INLINE #if defined(_MSC_VER) && !defined(__cplusplus) #define CMARK_INLINE __inline diff --git a/src/include/cmark-gfm_config.h b/src/include/cmark-gfm_config.h index 2905e964f..e6f0dea56 100644 --- a/src/include/cmark-gfm_config.h +++ b/src/include/cmark-gfm_config.h @@ -9,9 +9,7 @@ extern "C" { #endif -#define HAVE_STDBOOL_H - -#ifdef HAVE_STDBOOL_H +#if __has_include() #include #elif !defined(__cplusplus) typedef char bool; @@ -19,16 +17,8 @@ extern "C" { #define HAVE___BUILTIN_EXPECT -#define HAVE___ATTRIBUTE__ - #define CMARK_THREADING -#ifdef HAVE___ATTRIBUTE__ - #define CMARK_ATTRIBUTE(list) __attribute__ (list) -#else - #define CMARK_ATTRIBUTE(list) -#endif - #ifndef CMARK_INLINE #if defined(_MSC_VER) && !defined(__cplusplus) #define CMARK_INLINE __inline From 32891c293371ca5e3de3f19d30b672ec063621d2 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 11 Mar 2022 14:48:21 -0700 Subject: [PATCH 08/21] include windows.h instead of synchapi.h for win32 the win32 API uses some architecture-specific defines, but they're not defined by the MSVC compiler - they're defined directly in windows.h based on symbols defined by the MSVC compiler. rather than setting the architecture symbols ourselves, just import windows.h as a whole. this also needed to disable the short-name symbols in cmark-gfm.h, because there are some clashing symbols in win32 headers. --- src/include/cmark-gfm.h | 2 +- src/include/mutex.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/cmark-gfm.h b/src/include/cmark-gfm.h index 14ab95f4a..8aa378838 100644 --- a/src/include/cmark-gfm.h +++ b/src/include/cmark-gfm.h @@ -807,7 +807,7 @@ const char *cmark_version_string(void); * John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer. */ -#ifndef CMARK_NO_SHORT_NAMES +#if !defined(CMARK_NO_SHORT_NAMES) && !defined(_WIN32) #define NODE_DOCUMENT CMARK_NODE_DOCUMENT #define NODE_BLOCK_QUOTE CMARK_NODE_BLOCK_QUOTE #define NODE_LIST CMARK_NODE_LIST diff --git a/src/include/mutex.h b/src/include/mutex.h index 7335d8225..ded06f1bb 100644 --- a/src/include/mutex.h +++ b/src/include/mutex.h @@ -31,7 +31,7 @@ pthread_mutex_lock(&NAME##_lock); #elif defined(_WIN32) // building for windows #define _WIN32_WINNT 0x0600 -#include +#include #define CMARK_DEFINE_ONCE(NAME) static INIT_ONCE NAME##_once = INIT_ONCE_STATIC_INIT; From 7c1be3814f81a8f784ea1723daf7b95837bbe27c Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 11 Mar 2022 14:50:13 -0700 Subject: [PATCH 09/21] fix uninitialized-variable warning --- src/inlines.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inlines.c b/src/inlines.c index ddfb7814c..51d89a0ce 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -1100,7 +1100,7 @@ static bufsize_t manual_scan_attribute_attributes(cmark_chunk *input, bufsize_t static cmark_node *handle_close_bracket_attribute(cmark_parser *parser, subject *subj, bracket *opener) { bufsize_t startattributes, endattributes; - cmark_chunk attributes; + cmark_chunk attributes = CMARK_CHUNK_EMPTY; bufsize_t n; cmark_node *inl; cmark_chunk raw_label; From 7e40c7347f635a042fe509515484177e249a2631 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Fri, 11 Mar 2022 17:23:30 -0700 Subject: [PATCH 10/21] use CMake-generated {project}_export.h if available --- extensions/CMakeLists.txt | 2 +- extensions/include/cmark-gfm-core-extensions.h | 2 +- .../{cmark-gfm-extensions_export.h => extensions-export.h} | 5 +++++ src/CMakeLists.txt | 2 +- src/include/cmark-gfm.h | 2 +- src/include/cmark_ctype.h | 2 +- src/include/{cmark-gfm_export.h => export.h} | 5 +++++ 7 files changed, 15 insertions(+), 5 deletions(-) rename extensions/include/{cmark-gfm-extensions_export.h => extensions-export.h} (91%) rename src/include/{cmark-gfm_export.h => export.h} (91%) diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 8a2b47986..a50b3ed81 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -86,7 +86,7 @@ install(TARGETS ${CMARK_INSTALL} if (CMARK_SHARED OR CMARK_STATIC) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/cmark-gfm-core-extensions.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/cmark-gfm-extensions_export.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/extensions-export.h DESTINATION include ) diff --git a/extensions/include/cmark-gfm-core-extensions.h b/extensions/include/cmark-gfm-core-extensions.h index 51103e616..20da8d6e3 100644 --- a/extensions/include/cmark-gfm-core-extensions.h +++ b/extensions/include/cmark-gfm-core-extensions.h @@ -6,7 +6,7 @@ extern "C" { #endif #include "cmark-gfm-extension_api.h" -#include "cmark-gfm-extensions_export.h" +#include "extensions-export.h" #include "cmark-gfm_config.h" // for bool #include diff --git a/extensions/include/cmark-gfm-extensions_export.h b/extensions/include/extensions-export.h similarity index 91% rename from extensions/include/cmark-gfm-extensions_export.h rename to extensions/include/extensions-export.h index fe32014cd..1d4fc440d 100644 --- a/extensions/include/cmark-gfm-extensions_export.h +++ b/extensions/include/extensions-export.h @@ -1,3 +1,6 @@ +#if __has_include("cmark-gfm-extensions_export.h") +#include "cmark-gfm-extensions_export.h" +#else #ifndef CMARK_GFM_EXTENSIONS_EXPORT_H #define CMARK_GFM_EXTENSIONS_EXPORT_H @@ -50,3 +53,5 @@ #endif #endif /* CMARK_GFM_EXTENSIONS_EXPORT_H */ + +#endif /* "cmark-gfm-extensions_export.h" */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ffdb6ab88..1b9df402d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -152,7 +152,7 @@ if(CMARK_SHARED OR CMARK_STATIC) ${CMAKE_CURRENT_SOURCE_DIR}/include/cmark-gfm.h ${CMAKE_CURRENT_SOURCE_DIR}/include/cmark-gfm_config.h ${CMAKE_CURRENT_SOURCE_DIR}/include/cmark-gfm-extension_api.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/cmark-gfm_export.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/export.h ${CMAKE_CURRENT_SOURCE_DIR}/include/cmark-gfm_version.h DESTINATION include ) diff --git a/src/include/cmark-gfm.h b/src/include/cmark-gfm.h index 8aa378838..f3eee31b3 100644 --- a/src/include/cmark-gfm.h +++ b/src/include/cmark-gfm.h @@ -3,7 +3,7 @@ #include #include -#include "cmark-gfm_export.h" +#include "export.h" #include "cmark-gfm_version.h" #ifdef __cplusplus diff --git a/src/include/cmark_ctype.h b/src/include/cmark_ctype.h index 67c1cb037..4c2457e8c 100644 --- a/src/include/cmark_ctype.h +++ b/src/include/cmark_ctype.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include "cmark-gfm_export.h" +#include "export.h" /** Locale-independent versions of functions from ctype.h. * We want cmark to behave the same no matter what the system locale. diff --git a/src/include/cmark-gfm_export.h b/src/include/export.h similarity index 91% rename from src/include/cmark-gfm_export.h rename to src/include/export.h index 95e5da6d6..97b103999 100644 --- a/src/include/cmark-gfm_export.h +++ b/src/include/export.h @@ -1,3 +1,6 @@ +#if __has_include("cmark-gfm_export.h") +#include "cmark-gfm_export.h" +#else #ifndef CMARK_GFM_EXPORT_H #define CMARK_GFM_EXPORT_H @@ -40,3 +43,5 @@ #endif #endif /* CMARK_GFM_EXPORT_H */ + +#endif /* "cmark-gfm_export.h" */ From 60b6240cbc113f2394e71d866293d234a5eb421f Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 14 Mar 2022 09:39:39 -0600 Subject: [PATCH 11/21] use underscored visibility attribute Co-authored-by: Saleem Abdulrasool --- extensions/include/extensions-export.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/include/extensions-export.h b/extensions/include/extensions-export.h index 1d4fc440d..d4043bd53 100644 --- a/extensions/include/extensions-export.h +++ b/extensions/include/extensions-export.h @@ -24,14 +24,14 @@ # else # ifndef CMARK_GFM_EXTENSIONS_EXPORT # ifdef libcmark_gfm_extensions_EXPORTS -# define CMARK_GFM_EXTENSIONS_EXPORT __attribute__((visibility("default"))) +# define CMARK_GFM_EXTENSIONS_EXPORT __attribute__((__visibility__("default"))) # else -# define CMARK_GFM_EXTENSIONS_EXPORT __attribute__((visibility("default"))) +# define CMARK_GFM_EXTENSIONS_EXPORT __attribute__((__visibility__("default"))) # endif # endif # ifndef CMARK_GFM_EXTENSIONS_NO_EXPORT -# define CMARK_GFM_EXTENSIONS_NO_EXPORT __attribute__((visibility("hidden"))) +# define CMARK_GFM_EXTENSIONS_NO_EXPORT __attribute__((__visibility__("hidden"))) # endif # endif #endif From fbefbc3875a3cd61e8bc98129e9ce28f764a99ea Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Mon, 14 Mar 2022 10:29:38 -0600 Subject: [PATCH 12/21] use WIN32_LEAN_AND_MEAN to avoid symbol collisions --- src/include/cmark-gfm.h | 2 +- src/include/mutex.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/include/cmark-gfm.h b/src/include/cmark-gfm.h index f3eee31b3..aee012955 100644 --- a/src/include/cmark-gfm.h +++ b/src/include/cmark-gfm.h @@ -807,7 +807,7 @@ const char *cmark_version_string(void); * John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer. */ -#if !defined(CMARK_NO_SHORT_NAMES) && !defined(_WIN32) +#if !defined(CMARK_NO_SHORT_NAMES) #define NODE_DOCUMENT CMARK_NODE_DOCUMENT #define NODE_BLOCK_QUOTE CMARK_NODE_BLOCK_QUOTE #define NODE_LIST CMARK_NODE_LIST diff --git a/src/include/mutex.h b/src/include/mutex.h index ded06f1bb..c9fe185c6 100644 --- a/src/include/mutex.h +++ b/src/include/mutex.h @@ -30,7 +30,8 @@ pthread_mutex_lock(&NAME##_lock); #elif defined(_WIN32) // building for windows -#define _WIN32_WINNT 0x0600 +#define _WIN32_WINNT 0x0600 // minimum target of Windows Vista +#define WIN32_LEAN_AND_MEAN #include #define CMARK_DEFINE_ONCE(NAME) static INIT_ONCE NAME##_once = INIT_ONCE_STATIC_INIT; From 5bc7a2620d7bf73c19e1d2077d46f423efa5a775 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 14 Mar 2022 10:38:00 -0600 Subject: [PATCH 13/21] use C standard version to guard stdbool.h Co-authored-by: Saleem Abdulrasool --- src/config.h.in | 2 +- src/include/cmark-gfm_config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.h.in b/src/config.h.in index 463a10a00..14e6a1620 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -5,7 +5,7 @@ extern "C" { #endif -#if __has_include() +#if __STDC_VERSION__ >= 199901l #include #elif !defined(__cplusplus) typedef char bool; diff --git a/src/include/cmark-gfm_config.h b/src/include/cmark-gfm_config.h index e6f0dea56..e4cc4846e 100644 --- a/src/include/cmark-gfm_config.h +++ b/src/include/cmark-gfm_config.h @@ -9,7 +9,7 @@ extern "C" { #endif -#if __has_include() +#if __STDC_VERSION__ >= 199901l #include #elif !defined(__cplusplus) typedef char bool; From c505c99e4a890a291b48307a2b380f4027b412ad Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Mon, 14 Mar 2022 14:08:12 -0600 Subject: [PATCH 14/21] build with C11 on MSVC where it's supported --- api_test/CMakeLists.txt | 5 +++++ extensions/CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt index 056fc2da8..72fdc1042 100644 --- a/api_test/CMakeLists.txt +++ b/api_test/CMakeLists.txt @@ -29,3 +29,8 @@ if(MSVC) elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic") endif() + +# On MSVC 15.0 and newer, compile with C11 standard +if (MSVC AND MSVC_VERSION GREATER_EQUAL 1910) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11") +endif() diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index a50b3ed81..ad5ee953f 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -125,6 +125,11 @@ if(MSVC AND MSVC_VERSION LESS 1800) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP") endif() +# On MSVC 15.0 and newer, compile with C11 standard +if (MSVC AND MSVC_VERSION GREATER_EQUAL 1910) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11") +endif() + if(CMAKE_BUILD_TYPE STREQUAL "Ubsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b9df402d..5c4d5d721 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -191,6 +191,11 @@ if(MSVC AND MSVC_VERSION LESS 1800) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP") endif() +# On MSVC 15.0 and newer, compile with C11 standard +if (MSVC AND MSVC_VERSION GREATER_EQUAL 1910) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11") +endif() + if(CMAKE_BUILD_TYPE STREQUAL "Ubsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") endif() From e5e596e807f4e2cf58493ba3937d7121c9e3505d Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Mon, 14 Mar 2022 14:49:54 -0600 Subject: [PATCH 15/21] check for unistd.h during CMake or with more-compatible checks --- extensions/CMakeLists.txt | 6 +----- src/CMakeLists.txt | 1 + src/config.h.in | 2 ++ src/include/cmark-gfm_config.h | 9 +++++++++ src/include/mutex.h | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index ad5ee953f..5d312dec0 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -98,14 +98,10 @@ include(CheckIncludeFile) include(CheckCSourceCompiles) include(CheckCSourceRuns) include(CheckSymbolExists) -CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H) +CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) CHECK_C_SOURCE_COMPILES( "int main() { __builtin_expect(0,0); return 0; }" HAVE___BUILTIN_EXPECT) -CHECK_C_SOURCE_COMPILES(" - int f(void) __attribute__ (()); - int main() { return 0; } -" HAVE___ATTRIBUTE__) # Always compile with warnings if(MSVC) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c4d5d721..fe9fe763c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -165,6 +165,7 @@ include(CheckIncludeFile) include(CheckCSourceCompiles) include(CheckCSourceRuns) include(CheckSymbolExists) +CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) CHECK_C_SOURCE_COMPILES( "int main() { __builtin_expect(0,0); return 0; }" HAVE___BUILTIN_EXPECT) diff --git a/src/config.h.in b/src/config.h.in index 14e6a1620..f8f767a8b 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -11,6 +11,8 @@ extern "C" { typedef char bool; #endif +#cmakedefine HAVE_UNISTD_H + #cmakedefine HAVE___BUILTIN_EXPECT #cmakedefine CMARK_THREADING diff --git a/src/include/cmark-gfm_config.h b/src/include/cmark-gfm_config.h index e4cc4846e..9ed2dd993 100644 --- a/src/include/cmark-gfm_config.h +++ b/src/include/cmark-gfm_config.h @@ -15,6 +15,15 @@ extern "C" { typedef char bool; #endif +#if defined(__has_include) +# if __has_include() +# define HAVE_UNISTD_H +# endif +#elif defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__) + // Apple Clang does not define any of the unix symbols, even though it provides unistd.h +# define HAVE_UNISTD_H +#endif + #define HAVE___BUILTIN_EXPECT #define CMARK_THREADING diff --git a/src/include/mutex.h b/src/include/mutex.h index c9fe185c6..d2ad4787b 100644 --- a/src/include/mutex.h +++ b/src/include/mutex.h @@ -5,7 +5,7 @@ #ifdef CMARK_THREADING -#if __has_include() +#ifdef HAVE_UNISTD_H #include #endif From 66882531990d7d62e51c5fb385eea5ab797ed0fd Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Mon, 14 Mar 2022 14:51:22 -0600 Subject: [PATCH 16/21] use CMake headers via a build-time switch instead of __has_include --- api_test/CMakeLists.txt | 2 ++ extensions/CMakeLists.txt | 3 +++ extensions/include/extensions-export.h | 11 +++++++---- src/CMakeLists.txt | 3 +++ src/include/cmark-gfm_config.h | 15 +++++++++------ src/include/export.h | 15 +++++++++------ 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt index 72fdc1042..3817d994d 100644 --- a/api_test/CMakeLists.txt +++ b/api_test/CMakeLists.txt @@ -34,3 +34,5 @@ endif() if (MSVC AND MSVC_VERSION GREATER_EQUAL 1910) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11") endif() + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCMARK_USE_CMAKE_HEADERS") diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 5d312dec0..8a29cd126 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -103,6 +103,9 @@ CHECK_C_SOURCE_COMPILES( "int main() { __builtin_expect(0,0); return 0; }" HAVE___BUILTIN_EXPECT) +# Use CMake's generated headers instead of the Swift package prebuilt ones +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCMARK_USE_CMAKE_HEADERS") + # Always compile with warnings if(MSVC) # Force to always compile with W4 diff --git a/extensions/include/extensions-export.h b/extensions/include/extensions-export.h index d4043bd53..e2b220bad 100644 --- a/extensions/include/extensions-export.h +++ b/extensions/include/extensions-export.h @@ -1,10 +1,13 @@ -#if __has_include("cmark-gfm-extensions_export.h") -#include "cmark-gfm-extensions_export.h" -#else - #ifndef CMARK_GFM_EXTENSIONS_EXPORT_H #define CMARK_GFM_EXTENSIONS_EXPORT_H +#ifdef CMARK_USE_CMAKE_HEADERS +// if the CMake config header exists, use that instead of this Swift package prebuilt one +// we need to undefine the header guard, since export.h uses the same one +#undef CMARK_GFM_EXTENSIONS_EXPORT_H +#include "cmark-gfm-extensions_export.h" +#else + #ifdef CMARK_GFM_EXTENSIONS_STATIC_DEFINE # define CMARK_GFM_EXTENSIONS_EXPORT # define CMARK_GFM_EXTENSIONS_NO_EXPORT diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe9fe763c..e30425d16 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -174,6 +174,9 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +# Use CMake's generated headers instead of the Swift package prebuilt ones +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCMARK_USE_CMAKE_HEADERS") + # Always compile with warnings if(MSVC) # Force to always compile with W4 diff --git a/src/include/cmark-gfm_config.h b/src/include/cmark-gfm_config.h index 9ed2dd993..7d331915b 100644 --- a/src/include/cmark-gfm_config.h +++ b/src/include/cmark-gfm_config.h @@ -1,10 +1,13 @@ -#if __has_include("config.h") -#include "config.h" -#else - #ifndef CMARK_CONFIG_H #define CMARK_CONFIG_H +#ifdef CMARK_USE_CMAKE_HEADERS +// if the CMake config header exists, use that instead of this Swift package prebuilt one +// we need to undefine the header guard, since config.h uses the same one +#undef CMARK_CONFIG_H +#include "config.h" +#else + #ifdef __cplusplus extern "C" { #endif @@ -78,6 +81,6 @@ CMARK_INLINE int c99_snprintf(char *outBuf, size_t size, const char *format, ... } #endif -#endif /* CMARK_CONFIG_H */ +#endif /* not CMARK_USE_CMAKE_HEADERS */ -#endif /* config.h */ +#endif /* not CMARK_CONFIG_H */ diff --git a/src/include/export.h b/src/include/export.h index 97b103999..0e5f4d0f3 100644 --- a/src/include/export.h +++ b/src/include/export.h @@ -1,10 +1,13 @@ -#if __has_include("cmark-gfm_export.h") -#include "cmark-gfm_export.h" -#else - #ifndef CMARK_GFM_EXPORT_H #define CMARK_GFM_EXPORT_H +#ifdef CMARK_USE_CMAKE_HEADERS +// if the CMake config header exists, use that instead of this Swift package prebuilt one +// we need to undefine the header guard, since export.h uses the same one +#undef CMARK_GFM_EXPORT_H +#include "cmark-gfm_export.h" +#else + #ifdef CMARK_GFM_STATIC_DEFINE # define CMARK_GFM_EXPORT # define CMARK_GFM_NO_EXPORT @@ -42,6 +45,6 @@ # define CMARK_GFM_DEPRECATED_NO_EXPORT CMARK_GFM_NO_EXPORT CMARK_GFM_DEPRECATED #endif -#endif /* CMARK_GFM_EXPORT_H */ +#endif /* not CMARK_USE_CMAKE_HEADERS */ -#endif /* "cmark-gfm_export.h" */ +#endif /* not CMARK_GFM_EXPORT_H */ From 48dd1d83d64fe8fee07482d3b46c3a5892089757 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Tue, 15 Mar 2022 10:11:22 -0600 Subject: [PATCH 17/21] use CMAKE_C_STANDARD to set C standard --- CMakeLists.txt | 8 ++++++++ api_test/CMakeLists.txt | 5 ----- extensions/CMakeLists.txt | 5 ----- src/CMakeLists.txt | 5 ----- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae88d3817..a1e9742da 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,14 @@ option(CMARK_SHARED "Build shared libcmark-gfm library" ON) option(CMARK_LIB_FUZZER "Build libFuzzer fuzzing harness" OFF) option(CMARK_THREADING "Add locks around static accesses" OFF) +# set a required C standard so we can load stdbool.h +if(MSVC) + set(CMAKE_C_STANDARD 11) +else() + set(CMAKE_C_STANDARD 99) +endif() +set(CMAKE_C_STANDARD_REQUIRED YES) + add_subdirectory(src) add_subdirectory(extensions) if(CMARK_TESTS AND (CMARK_SHARED OR CMARK_STATIC)) diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt index 3817d994d..d40e78897 100644 --- a/api_test/CMakeLists.txt +++ b/api_test/CMakeLists.txt @@ -30,9 +30,4 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic") endif() -# On MSVC 15.0 and newer, compile with C11 standard -if (MSVC AND MSVC_VERSION GREATER_EQUAL 1910) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11") -endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCMARK_USE_CMAKE_HEADERS") diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 8a29cd126..dc1ddc79d 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -124,11 +124,6 @@ if(MSVC AND MSVC_VERSION LESS 1800) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP") endif() -# On MSVC 15.0 and newer, compile with C11 standard -if (MSVC AND MSVC_VERSION GREATER_EQUAL 1910) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11") -endif() - if(CMAKE_BUILD_TYPE STREQUAL "Ubsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e30425d16..bc1d99655 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,11 +195,6 @@ if(MSVC AND MSVC_VERSION LESS 1800) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP") endif() -# On MSVC 15.0 and newer, compile with C11 standard -if (MSVC AND MSVC_VERSION GREATER_EQUAL 1910) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11") -endif() - if(CMAKE_BUILD_TYPE STREQUAL "Ubsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") endif() From 492f0b5cdd818e359633e895da50e4cfdef8d56f Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Tue, 15 Mar 2022 13:03:42 -0600 Subject: [PATCH 18/21] set CMARK_USE_CMAKE_HEADERS at the top level --- CMakeLists.txt | 5 ++++- api_test/CMakeLists.txt | 2 -- extensions/CMakeLists.txt | 3 --- src/CMakeLists.txt | 3 --- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1e9742da..29202f574 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.12) project(cmark-gfm) set(PROJECT_VERSION_MAJOR 0) @@ -28,6 +28,9 @@ else() endif() set(CMAKE_C_STANDARD_REQUIRED YES) +# Use CMake's generated headers instead of the Swift package prebuilt ones +add_compile_definitions(CMARK_USE_CMAKE_HEADERS) + add_subdirectory(src) add_subdirectory(extensions) if(CMARK_TESTS AND (CMARK_SHARED OR CMARK_STATIC)) diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt index d40e78897..056fc2da8 100644 --- a/api_test/CMakeLists.txt +++ b/api_test/CMakeLists.txt @@ -29,5 +29,3 @@ if(MSVC) elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic") endif() - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCMARK_USE_CMAKE_HEADERS") diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index dc1ddc79d..3f7ca1680 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -103,9 +103,6 @@ CHECK_C_SOURCE_COMPILES( "int main() { __builtin_expect(0,0); return 0; }" HAVE___BUILTIN_EXPECT) -# Use CMake's generated headers instead of the Swift package prebuilt ones -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCMARK_USE_CMAKE_HEADERS") - # Always compile with warnings if(MSVC) # Force to always compile with W4 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bc1d99655..9c90ddc19 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -174,9 +174,6 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) -# Use CMake's generated headers instead of the Swift package prebuilt ones -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCMARK_USE_CMAKE_HEADERS") - # Always compile with warnings if(MSVC) # Force to always compile with W4 From 4d1fe42464eb3f394670c9ded39d73ae16fae6dd Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Tue, 15 Mar 2022 15:42:28 -0600 Subject: [PATCH 19/21] use const char * for string literals --- api_test/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api_test/main.c b/api_test/main.c index 1051c2904..2e497ce95 100644 --- a/api_test/main.c +++ b/api_test/main.c @@ -1192,7 +1192,7 @@ static void inline_only_opt(test_batch_runner *runner) { cmark_node_free(doc); } -static void check_markdown_plaintext(test_batch_runner *runner, char *markdown) { +static void check_markdown_plaintext(test_batch_runner *runner, const char *markdown) { cmark_node *doc = cmark_parse_document(markdown, strlen(markdown), CMARK_OPT_PRESERVE_WHITESPACE); cmark_node *pg = cmark_node_first_child(doc); INT_EQ(runner, cmark_node_get_type(pg), CMARK_NODE_PARAGRAPH, "markdown '%s' did not produce a paragraph node", markdown); @@ -1228,7 +1228,7 @@ static void preserve_whitespace_opt(test_batch_runner *runner) { check_markdown_plaintext(runner, "\nHello\n"); } -static void check_markdown_attributes_node(test_batch_runner *runner, char *markdown, cmark_node_type expectedType, char *expectedAttributes) { +static void check_markdown_attributes_node(test_batch_runner *runner, const char *markdown, cmark_node_type expectedType, const char *expectedAttributes) { cmark_node *doc = cmark_parse_document(markdown, strlen(markdown), CMARK_OPT_DEFAULT); cmark_node *pg = cmark_node_first_child(doc); INT_EQ(runner, cmark_node_get_type(pg), CMARK_NODE_PARAGRAPH, "markdown '%s' did not produce a paragraph node", markdown); From 87fa5e70f390b1491215553326b0052dafd7e71f Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Tue, 15 Mar 2022 16:01:25 -0600 Subject: [PATCH 20/21] use __declspec(deprecated) for deprecated functions on Windows --- extensions/include/extensions-export.h | 6 +++--- src/include/export.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/include/extensions-export.h b/extensions/include/extensions-export.h index e2b220bad..f91b8564c 100644 --- a/extensions/include/extensions-export.h +++ b/extensions/include/extensions-export.h @@ -40,10 +40,10 @@ #endif #ifndef CMARK_GFM_EXTENSIONS_DEPRECATED -# if !defined(_WIN32) -# define CMARK_GFM_EXTENSIONS_DEPRECATED __attribute__ ((__deprecated__)) +# if defined(_WIN32) +# define CMARK_GFM_EXTENSIONS_DEPRECATED __declspec(deprecated) # else -# define CMARK_GFM_EXTENSIONS_DEPRECATED +# define CMARK_GFM_EXTENSIONS_DEPRECATED __attribute__ ((__deprecated__)) # endif #endif diff --git a/src/include/export.h b/src/include/export.h index 0e5f4d0f3..c219c6f54 100644 --- a/src/include/export.h +++ b/src/include/export.h @@ -30,10 +30,10 @@ #endif #ifndef CMARK_GFM_DEPRECATED -# if !defined(_WIN32) -# define CMARK_GFM_DEPRECATED __attribute__ ((__deprecated__)) +# if defined(_WIN32) +# define CMARK_GFM_DEPRECATED __declspec(deprecated) # else -# define CMARK_GFM_DEPRECATED +# define CMARK_GFM_DEPRECATED __attribute__ ((__deprecated__)) # endif #endif From 07f45bf55664a2b1283eab3f4acede56b5726ff0 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Thu, 17 Mar 2022 17:57:31 -0600 Subject: [PATCH 21/21] disable MSVC warning C5105 on Windows SDK version 10.0.17763.0, the SDK headers spuriously trip this warning. since swift-cmark itself doesn't emit this warning on its own, diabling this warning will allow it to be built with this SDK. --- api_test/CMakeLists.txt | 2 +- extensions/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt index 2ae27d762..07aa8b313 100644 --- a/api_test/CMakeLists.txt +++ b/api_test/CMakeLists.txt @@ -24,7 +24,7 @@ if(MSVC) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4706 /D_CRT_SECURE_NO_WARNINGS") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4706 /wd5105 /D_CRT_SECURE_NO_WARNINGS") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP") elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic") diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 4977c98c3..9503de992 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -115,7 +115,7 @@ if(MSVC) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4706 /wd4204 /wd4221 /wd4100 /D_CRT_SECURE_NO_WARNINGS") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4706 /wd4204 /wd4221 /wd4100 /wd5105 /D_CRT_SECURE_NO_WARNINGS") elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99 -pedantic") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7018903c..ba1404a54 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,7 +186,7 @@ if(MSVC) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4706 /wd4204 /wd4221 /wd4100 /D_CRT_SECURE_NO_WARNINGS") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4706 /wd4204 /wd4221 /wd4100 /wd5105 /D_CRT_SECURE_NO_WARNINGS") elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99 -pedantic") endif()