[m-dev.] Building with MSVC

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Dec 12 01:53:16 AEDT 2007


On Tue, 11 Dec 2007, Sergey Khorev wrote:

> 2) rotd-2007-12-09 introduced unportable code in runtime/mercury_wrapper.c 
> (see below)
> Perhaps /proc should be used in Unix environment only.
> Also in MSVC world snprintf is known as _snprintf so there should be 
> something like
> #if defined(MR_HAVE__SNPRINTF) && ! defined(MR_HAVE_SNPRINTF)
>  #define snprintf	_snprintf
> #endif
>
>
> #ifdef MR_HAVE_SYS_STAT_H
>    if (MR_mem_usage_report_prefix != NULL) {
>        struct stat statbuf;
>        char        filename_buf[MAX_MEM_USAGE_REPORT_CMD_SIZE];
>        char        cmd_buf[MAX_MEM_USAGE_REPORT_CMD_SIZE];
>        int         i;
>
>        for (i = 1; i < MAX_MEM_USAGE_REPORT_ATTEMPTS; i++) {
>            snprintf(filename_buf, MAX_MEM_USAGE_REPORT_CMD_SIZE,
>                "%s%02d", MR_mem_usage_report_prefix, i);
>
>            if (stat(filename_buf, &statbuf) == 0) {
>                /* Filename_buf exists; try next name. */
>                continue;
>            }
>
>            snprintf(cmd_buf, MAX_MEM_USAGE_REPORT_CMD_SIZE,
>                "cp /proc/%d/status %s", getpid(), filename_buf);
>            system(cmd_buf);
>            break;

As part of the change that introduced this code it was noted that
it wasn't portable.  We should just conditionally not include it
on Windows (except with Cygwin where it should work.)

Julien.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list