I'm trying to access code written using the SDL library for C and C++. However, the only way of reading C or C++ code using ctypes seems to be as a .so library or .dll file - I may be wrong, though. Is there a way of accessing plain .c or .cpp files using ctypes, or do I need to use a different library if there's one that can do that at all? Thanks in advance.
#๐ A way of reading plain C / C++ files
12 messages ยท Page 1 of 1 (latest)
@astral fossil
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
.c and .cpp files are just raw code, a computer cannot execute them at all. This is one of the main differences between C-like languages and python actually. They are compiled, python is interpreted. What this means is: a .py file is actual code, runnable by a computer. A .cpp file is not.
I'd suggest compiling your code to a .dll/.so using an appropriate compiler. If this code is written by someone else, check if there is an automated process to do just that. Most libraries have a Makefile, so you can just run an appropriate command (make ...) and it'll build all the required stuff
Runnable not by computer but the interpreter but yes
Yeah, meant that
This is the way c is faster too bc it doesn't need an interpreter after the compileing it runs on the processor skipping the resources of the interpreter
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.