[pcre-dev] [Bug 953] New: Visual C++ warning in pcre_globals…

Páxina inicial
Borrar esta mensaxe
Autor: Dair Grant
Data:  
Para: pcre-dev
Asunto: [pcre-dev] [Bug 953] New: Visual C++ warning in pcre_globals.c
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=953
           Summary: Visual C++ warning in pcre_globals.c
           Product: PCRE
           Version: 8.01
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
        AssignedTo: ph10@???
        ReportedBy: dair@???
                CC: pcre-dev@???



pcre_globals.c can generate warnings when built with Visual Studio:

1>Compiling...
1>pcre_globals.c
1>..\pcre_7.8\pcre_globals.c(67) : warning C4232: nonstandard extension used :
1> 'pcre_malloc' : address of dllimport 'malloc' is not static, identity not
guaranteed
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdlib.h(601) :
see declaration of 'malloc'
1>..\pcre_7.8\pcre_globals.c(68) : warning C4232: nonstandard extension used :
'pcre_free' :
1> address of dllimport 'free' is not static, identity not guaranteed
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdlib.h(600) :
see declaration of 'free'
1>..\pcre_7.8\pcre_globals.c(69) : warning C4232: nonstandard extension used :
'pcre_stack_malloc' :
1> address of dllimport 'malloc' is not static, identity not guaranteed
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdlib.h(601) :
see declaration of 'malloc'
1>..\pcre_7.8\pcre_globals.c(70) : warning C4232: nonstandard extension used :
'pcre_stack_free' :
1> address of dllimport 'free' is not static, identity not guaranteed
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdlib.h(600) :
see declaration of 'free'

These relate to http://msdn.microsoft.com/en-us/library/da6zd0a4.aspx and seem
to be due to taking the address of a symbol contained within an external DLL.

A fix is to initialise the globals to the address of a local function instead:

static void *glue_malloc(size_t theSize)
{
    return(malloc(theSize));
}


static void glue_free(void *thePtr)
{
    free(thePtr);
}


PCRE_EXP_DATA_DEFN void *(*pcre_malloc)(size_t) = glue_malloc;
PCRE_EXP_DATA_DEFN void (*pcre_free)(void *) = glue_free;
PCRE_EXP_DATA_DEFN void *(*pcre_stack_malloc)(size_t) = glue_malloc;
PCRE_EXP_DATA_DEFN void (*pcre_stack_free)(void *) = glue_free;
PCRE_EXP_DATA_DEFN int (*pcre_callout)(pcre_callout_block *) = NULL;


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email