Picol  Old Windows compilers

Compiling for old microsoft compilers

This pages lists the changes required to compile picol for Windows CE 5 and 6.

Visual Studio 2008

  • set PICOL_FEATURE_IO to 0
  • getenv() does not exist, so in the function picolGetVar2(), add a #if PICOL_FEATURE_IO like so:

     picolVar* picolGetVar2(picolInterp* interp, const char* name, int global) {
     ...
     #if PICOL_FEATURE_IO
            if (v == NULL) {
                if ((coloned || interp->callframe->parent == NULL)
                        && PICOL_EQ(buf, "env")) {
                    cp2 = getenv(buf2);
                    if (cp2 == NULL) {
                        return NULL;
                    }
                    strcpy(buf, "::env(");
                    strncat(buf, buf2, sizeof(buf) - strlen(buf2));
                    strncat(buf, ")", sizeof(buf) - 1);
                    return picolArrSetByName(interp, buf, cp2);
                } else {
                    return NULL;
                }
            }
     #endif /* PICOL_FEATURE_IO */
     ...
     }
    

  • There is no time_t either, so add a define to remove PICOL_COMMAND(clock)

    #if PICOL_FEATURE_TIME
    PICOL_COMMAND(clock) {
        time_t t;
        ...
        return PICOL_OK;
    }
    #endif

And in the place it gets registered:

    #if PICOL_FEATURE_TIME
        picolRegisterCmd(interp, "clock",    picol_clock, NULL);
    #endif
  • Because we don't have time() we also can't use the srand(time(NULL)) in picolCreateInterp2(). As a possible solution you could change the "int randomize" argument to be the random number itself:
    if (random) {
    #if PICOL_FEATURE_TIME
            srand(time(NULL));
    #else
            srand(random);
    #endif
    }

Microsoft Visual Embedded C++ 4.0

EVC++ does not support Variadic macro's. So in addition to the changes for VS2008, you also need to manually expand all the uses of PICOL_SNPRINTF