[Python-Dev] Suggestion/ feature request

Julian julvar at tamu.edu
Tue Nov 21 07:29:45 CET 2006


> -----Original Message-----
> From: "Martin v. Löwis" [mailto:martin at v.loewis.de] 
> Sent: Tuesday, November 21, 2006 12:01 AM
> To: Julian
> Cc: python-dev at python.org
> Subject: Re: [Python-Dev] Suggestion/ feature request
> 
> Julian schrieb:
> > I am using python with swig and I get a lot of macro redefinition 
> > warnings like so:
> > warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
> > 
> > In the file - pyconfig.h - rather than the following lines, I was 
> > wondering if it would be more reasonable to use #ifdef 
> statements as 
> > shown in the bottom of the email...
> 
> While I agree that would be reasonable, I also wonder why you 
> are getting these errors. Where is the first definition of 
> these macros, and how is the macro defined at the first definition?
> 
> Regards,
> Martin

In my specific case, the order of the definitions in any wrapper file
created by SWIG (I am using Version 1.3.30) looks like this:
//example_wrap.cxx
//snipped code
/* Deal with Microsoft's attempt at deprecating C standard runtime functions
*/
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) &&
!defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif


/* Python.h has to appear first */
#include <Python.h>

//snipped code

SWIG seems to have done it properly by checking to see if it has been
defined already (which, I think, is how python should do it as well)
Now, even if I am not using SWIG, I could imagine these being defined
elsewhere (by other headers/libraries) or even by setting them in the VS2005
IDE project settings (which I actually do sometimes). While these are *just*
warnings and not errors, it would look cleaner if pyconfig.h would check if
they were defined already.

Julian.



More information about the Python-Dev mailing list