Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Build: avoid win32-incompatible functions #2019

Merged
merged 1 commit into from

2 participants

Geoffroy Billotey Michael Droettboom
Geoffroy Billotey

Dating from commit e1e0848, I have been experimenting compiling errors (under win32).

c:\users\geoffroy\documents\github\matplotlib\src\path_converters.h(895) : error C3861: 'seed48': identifier not found
        c:\users\geoffroy\documents\github\matplotlib\src\path_converters.h(893) : while compiling class template member function 'void Sketch<VertexSource>::rewind(unsigned int)'
        with
        [
            VertexSource=curve_t
        ]
        src/_path.cpp(1516) : see reference to class template instantiation 'Sketch<VertexSource>' being compiled
        with
        [
            VertexSource=curve_t
        ]

They seem to be linked with the use of traditional UNIX functions like drand48 in path_converters.h. seed48 and M_PI are also problematic.

Enclosed is a patch attempt which uses ANSI C function rand and srand instead, and at least compile correctly - with win SDK. (The code being quite complex I can't be sure with my limited C++ knowledge this is the best way to deal with it ; hope it can help though)

Michael Droettboom
Owner

Indeed. I should have been more careful about sticking to ANSI C. Thanks for the PR.

Michael Droettboom mdboom merged commit f311ef5 into from
Geoffroy Billotey GBillotey deleted the branch
Geoffroy Billotey

Thanks for the merge.

While having a last read:
shouldn't I have used doubles instead of floats for _drand and _M_PI ? If you confirm, I would be happy to do the short corrective PR (sorry, I should have paid more attention in the first place).

Michael Droettboom
Owner

Indeed. Thanks for catching that. Practically speaking, I don't think it much matters on images of reasonably normal size. However, we should probably be consistent with doubles everywhere (since that's what's used for vertices in general).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 16, 2013
  1. Geoffroy Billotey
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/path_converters.h
9 src/path_converters.h
View
@@ -866,8 +866,10 @@ class Sketch
if (m_has_last) {
// We want the "cursor" along the sine wave to move at a
// random rate.
- m_p += pow(m_randomness, drand48() * 2.0 - 1.0);
- double r = sin(m_p / (m_length / (M_PI * 2.0))) * m_scale;
+ float _drand48 = rand() / float(RAND_MAX);
+ float _M_PI = 3.14159265358979323846;
+ m_p += pow(m_randomness, _drand48 * 2.0 - 1.0);
+ double r = sin(m_p / (m_length / (_M_PI * 2.0))) * m_scale;
double den = m_last_x - *x;
double num = m_last_y - *y;
double len = num*num + den*den;
@@ -891,8 +893,7 @@ class Sketch
inline void
rewind(unsigned path_id)
{
- unsigned short seed[] = {0, 0, 0};
- seed48(seed);
+ srand(0);
m_has_last = false;
m_p = 0.0;
if (m_scale != 0.0) {
Something went wrong with that request. Please try again.