I have some C code that is wrapped in a preprocessor directive:
#if defined(TEST)
// do stuff
#endif
and I need to execute do stuff from Python via ctypes – is there any way I can define TEST?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This has nothing at all to do with
ctypesor python. ctypes only deals with already compiled libraries and allows you to call functions in them. If you want to execute a function that is only conditionally defined you’ll have to compile the library with the right directives set.In gcc that would be something like
gcc -D TEST <rest as usual>