Skip to content

Commit

Permalink
Fix more errors with msys2 ucrt platform
Browse files Browse the repository at this point in the history
_mkdir being undefined:

    [ 81%] Building C object src/CMakeFiles/madx.dir/mad_sstate.c.obj
    C:\Users\Thomas\dev\hit\cpymad\src\MAD-X\src\mad_sstate.c: In function 'store_state':
    C:\Users\Thomas\dev\hit\cpymad\src\MAD-X\src\mad_sstate.c:42:5: error: implicit declaration of function '_mkdir'; did you mean 'mkdir'? [-Wimplicit-function-declaration]
       42 |     _mkdir(dir_name);
          |     ^~~~~~
          |     mkdir

and lots of undefined symbols (ad_alloc_, ad_free_, ...) in PTC.
  • Loading branch information
coldfix committed Dec 17, 2024
1 parent 391d596 commit 2bc0353
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/patch/fix-madx-win32.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/libs/ptc/src/tpsa.h b/libs/ptc/src/tpsa.h
index 4a2f15bc..b0b3174c 100644
--- a/libs/ptc/src/tpsa.h
+++ b/libs/ptc/src/tpsa.h
@@ -11,7 +11,7 @@
//! \version $Id: tpsa.h,v 1.4 2009-04-17 17:32:23 frs Exp $
//! \author Lingyun Yang, http://www.lingyunyang.com/

-#ifndef WIN32
+#if !defined(WIN32) || defined(__GNUC__)

/* should work unchanged on _win32 using Lahey */
#define ad_print ad_print_
diff --git a/src/mad_sstate.c b/src/mad_sstate.c
index fe909635..044ed409 100644
--- a/src/mad_sstate.c
+++ b/src/mad_sstate.c
@@ -1,4 +1,5 @@
#include "madx.h"
+#include <direct.h> // _mkdir()

static void
move_files(const char* orig_name,const char* append,const char* dirname){
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ jobs:
src/MAD-X -b $MADX_VERSION --depth 1
if: steps.madx-build-cache.outputs.cache-hit != 'true'

- name: Apply patches
if: steps.madx-build-cache.outputs.cache-hit != 'true'
run: patch -d src/MAD-X -p1 <.github/patch/fix_mkdir.patch
- name: Build MAD-X
if: steps.madx-build-cache.outputs.cache-hit != 'true'
run: .github/build/windows/madx.sh src/MAD-X
Expand Down

0 comments on commit 2bc0353

Please sign in to comment.