From 4ac17daad22b3212a543ca98d2323fe75b28bf6d Mon Sep 17 00:00:00 2001 From: Vojtech Kral <vojtech@kral.hk> Date: Tue, 15 May 2018 16:16:09 +0200 Subject: [PATCH] avrdude: Use C99, fix alloca include in stk500 --- xs/src/avrdude/CMakeLists.txt | 8 ++++++++ xs/src/avrdude/stk500.c | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/xs/src/avrdude/CMakeLists.txt b/xs/src/avrdude/CMakeLists.txt index b971452ee..d7a0f2021 100644 --- a/xs/src/avrdude/CMakeLists.txt +++ b/xs/src/avrdude/CMakeLists.txt @@ -2,6 +2,13 @@ remove_definitions(-D_UNICODE -DUNICODE) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Workaround for an old CMake, which does not understand CMAKE_C_STANDARD. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall") +endif() set(AVRDUDE_SOURCES @@ -64,6 +71,7 @@ if (WIN32) ) endif() add_library(avrdude STATIC ${AVRDUDE_SOURCES}) + if (WIN32) target_compile_definitions(avrdude PRIVATE WIN32NATIVE=1) target_include_directories(avrdude SYSTEM PRIVATE ${LIBDIR}/avrdude/windows) # So that sources find the getopt.h windows drop-in diff --git a/xs/src/avrdude/stk500.c b/xs/src/avrdude/stk500.c index 24052940b..987589305 100644 --- a/xs/src/avrdude/stk500.c +++ b/xs/src/avrdude/stk500.c @@ -35,7 +35,9 @@ #include <string.h> #include <errno.h> #include <unistd.h> -#include <malloc.h> +#if defined(WIN32NATIVE) +# include <malloc.h> /* for alloca() */ +#endif #include "avrdude.h" #include "libavrdude.h"