Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications to support MSVC compiler #165

Closed
purpledawn777 opened this issue May 26, 2022 · 1 comment
Closed

Modifications to support MSVC compiler #165

purpledawn777 opened this issue May 26, 2022 · 1 comment
Labels
installation Problems with the Installation of the pyunicorn package, especially windows. maintenance something should be improved or is outdated
Milestone

Comments

@purpledawn777
Copy link

Hello, fyi the following modifications need to be made to support microsoft's compiler (srand48,drand48 and c99 dynamic arrays not supported):
core/_ext/src_numerics.c
add this below the #includes:
#ifdef _MSC_VER
#define srand48(x) srand((x))
#define drand48() (rand()/(RAND_MAX + 1.0))
#endif

funcnet/_ext/src_numerics.c
in _get_nearest_neighbors_fast,
change:
int i, j, index=0, t, m, n, d, kxz, kyz, kz, indexfound[T];
double dz=0., dxyz=0., dx=0., dy=0., eps, epsmax;
double dist[Tdim], dxyzarray[k+1];
to:
int i, j, index=0, t, m, n, d, kxz, kyz, kz;
int
indexfound = (int*) malloc(sizeof(int)T);
double dz=0., dxyz=0., dx=0., dy=0., eps, epsmax;
double
dist = (double*)malloc(sizeof(double)Tdim);
double* dxyzarray = (double*) malloc(sizeof(double)*(k+1));

and add to the end of the method:
free(dist);
free(dxyzarray);
free(indexfound);

ntfrgl added a commit that referenced this issue Jun 27, 2023
- Builds on: 79ded90
- Related issues: #159, #160
- Resolves issue: #165
- Eliminate `{s|d}rand48()` calls via overdue Cythonizing
- Avoid some more C99 variable length arrays
- Reference more detailed Windows installation instructions
@ntfrgl
Copy link
Member

ntfrgl commented Jun 27, 2023

Thank you for your contribution, @purpledawn777! The commit above adopts a similar approach, although it uses Cython for the functions requiring random numbers and alloca instead of malloc/free.

@ntfrgl ntfrgl closed this as completed Jun 27, 2023
@ntfrgl ntfrgl added this to the Release 0.7 milestone Dec 1, 2023
@ntfrgl ntfrgl added installation Problems with the Installation of the pyunicorn package, especially windows. maintenance something should be improved or is outdated labels Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation Problems with the Installation of the pyunicorn package, especially windows. maintenance something should be improved or is outdated
Projects
None yet
Development

No branches or pull requests

2 participants