What is ctypes data for BOOL?
I mean in C++ to ctypes we have:
int--> c_int
float--> c_float
what about BOOL?

I got it!

from ctypes.wintypes import BOOL
#then you can use BOOL anywhere in your code

A word of warning, be careful using ctypes.wintypes.BOOL as a C++ bool equivalent. From the documentation at http://epydoc.sourceforge.net/stdlib/ctypes.wintypes-module.html BOOL is described as a c_long type (4 bytes). Microsoft seem to have complicated matters by changing their compiler (http://msdn.microsoft.com/en-us/library/tf4dy80a.aspx)

In Visual C++4.2, the Standard C++ header files contained a typedef that equated bool with int. In Visual C++ 5.0 and later, bool is implemented as a built-in type with a size of 1 byte. That means that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in Visual C++ 5.0 and later, the same call yields 1. This can cause memory corruption problems if you have defined structure members of type bool in Visual C++ 4.2 and are mixing object files (OBJ) and/or DLLs built with the 4.2 and 5.0 or later compilers.

The __BOOL_DEFINED macro can be used to wrap code that is dependent on whether or not bool is supported.

I'm currently having problems with memory access violations when passing a ctypes.wintypes.BOOL to a DLL and I wouldn't be surprised if it's because I'm passing 4 bytes when it's expecting 1 byte.

Cheers,

Paul

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.