Feature Requests item #1612190, was opened at 2006-12-09 10:48
Message generated for change (Comment added) made by collinwinter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1612190&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Private: No
Submitted By: nitro (nitrogenycs)
Assigned to: Nobody/Anonymous (nobody)
Summary: Py_DEBUG

Initial Comment:
Hello,
 
I am writing an extension module (Win32, VC8). Of course I need to #include 
<Python.h>. Now, when _DEBUG is defined in my application Py_DEBUG gets defined 
as well (in pyconfig.h). I don't want this to happen as I have to link to the 
python debug library that way. However, I don't want to debug python, I only 
want to debug my own application. So the automatic definition of Py_DEBUG 
doesn't seem right. A solution that would be backwards compatible could look 
like:
 
#ifdef _DEBUG && !defined(Py_NO_DEBUG)
#       define Py_DEBUG
#endif
 
Could something like this be included in python? Note that #undef _DEBUG 
#include <Python.h> #define _DEBUG does not work as VC8 complains in this case, 
because some header files had the _DEBUG preprocessor symbol and some didn't. 
That trick used to work in VC 6 and 7.x. I've seen a lot of people fighting 
this problem.
 
Another problem that also arises from pyconfig.h is this code:
 
#                       ifdef _DEBUG
#                               pragma comment(lib,"python24_d.lib")
#                       else
 
I don't think it's clean that python tells my program what to link to. I am the 
one who should (and wants to) do this via a linker switch. I know that some 
people probably would regard the code above as a feature, but it's the opposite 
imo. A backwards compatible change could look like:
 
#ifdef MS_COREDLL
#       ifndef Py_BUILD_CORE /* not building the core - must be an ext */
#               if defined(_MSC_VER) && !defined(Py_NO_AUTOMATIC_MSVC_LINK)
                        /* So MSVC users need not specify the .lib file in
                        their Makefile (other compilers are generally
                        taken care of by distutils.) */
#                       ifdef _DEBUG
#                               pragma comment(lib,"python24_d.lib")
#                       else
#                               pragma comment(lib,"python24.lib")
#                       endif /* _DEBUG */
#               endif /* _MSC_VER */
#       endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */

Thanks,

-Matthias

----------------------------------------------------------------------

>Comment By: Collin Winter (collinwinter)
Date: 2007-03-30 10:40

Message:
Logged In: YES 
user_id=1344176
Originator: NO

Closing per Martin's comment.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2006-12-11 14:09

Message:
Logged In: YES 
user_id=21627
Originator: NO

You should just not define _DEBUG then. You don't need to define _DEBUG to
perform debugging; instead, _DEBUG requests that the debug version of the
MS CRT is linked to your application.

As mixing different CRTs (e.g. debug and non-debug) in a single
application can cause crashes, you *must* use a python2x.dll that is linked
with the debug CRT; this will be python2x_d.dll. So no, something like this
should not be added to Python.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1612190&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to