Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-09 Thread Brad M
Hmmm, I guess then it's time for me to ask this question: Is how I do this the way you do it? I have been inserting lines like this: print("The program got here!") all over my python code whenever I want to know where the program went. If you want to know where your program went when something

Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-09 Thread James Chapman
A long time ago when I was working with Python and DLLs I slapped together a basic and ugly example. You can find it here: https://github.com/James-Chapman/python-code-snippets/ tree/master/DLL_C_funcs_w_callbacks The whole thing should load into Visual Studio. I can't guarantee that it works in i

Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread eryk sun
On Wed, May 9, 2018 at 1:30 AM, Brad M wrote: > > If you want to know where your program went when something went wrong or > when it triggers a if condition, how do you do it? Look into use the logging module [1] and debuggers [2], either dedicated like Winpdb or in an IDE such as PyCharm. [1]:

Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread eryk sun
On Tue, May 8, 2018 at 9:39 AM, Brad M wrote: > > I compile this by typing this in the command line: > cl /LD /I C:\python\include helloworld.c C:\python\libs\python36.lib You're not using Python's C API, so you only need `cl /LD helloworld.c`. > However, this doesn't print anything on the pytho

Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread Alan Gauld via Tutor
I'm guessing at the answer here because I'm on vacation with no access to a pc of any kind let alone Windows. But are you running python inside an ide? If so you might find you get the expected result if you use a command prompt, since printf usually sends output to stdout. This is another exam

[Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread Brad M
Hi all: I am trying out some c based module in a .dll file on windows. // helloworld.c #include __declspec(dllexport) void helloworld() { printf("Hello Everyone!!!"); } I compile this by typing this in the command line: cl /LD /I C:\python\include helloworld.c C:\python\libs\python36.lib