Hi,
On 23 January 2017 at 05:29, M P <
bmpe...@gmail.com> wrote:
> 1. CFFI_DLLEXPORT macro causes compiler issues. The compiler says it
> defaults to int.
>
> #ifndef CFFI_DLLEXPORT
> #define CFFI_DLLEXPORT __declspec(dllimport)
> #endif
>
> CFFI_DLLEXPORT void runStrategyBasic(struct _AlgoServer *);
Ah, I see that you copied these four lines from the docs. That part
of the docs was supposed to be Windows-friendly but was actually
Windows-*only* by mistake. It doesn't compile with gcc. I've fixed
the docs to put a version that compiles on both, see here:
/* file plugin.h, Windows-friendly version */
typedef struct { int x, y; } point_t;
/* When including this file from ffibuilder.set_source(), the
following macro is defined to '__declspec(dllexport)'. When
including this file directly from your C program, we define
it to 'extern __declspec(dllimport)' instead.
With non-MSVC compilers we simply define it to 'extern'.
(The 'extern' is needed for sharing global variables;
functions would be fine without it. The macros always
include 'extern': you must not repeat it when using the
macros later.)
*/
#ifndef CFFI_DLLEXPORT
# if defined(_MSC_VER)
# define CFFI_DLLEXPORT extern __declspec(dllimport)
# else
# define CFFI_DLLEXPORT extern
# endif
#endif
CFFI_DLLEXPORT int do_stuff(point_t *);
(Please tell me if there are still problems.)
> 2. Python does not recognize the void pointers as attributes from my struct.
> (...)
> @ffi.def_extern()
> def runStrategyBasic(server):
It is not very clear to me what you're trying to achieve. From this
def_extern() with name "runStrategyBasic" I guess you're also trying
to use the code found in your question #1, but it's not clear how.
Can you give a complete example that I can reproduce? Your question
is close, but not quite there: please give all files with their names,
and tell what you're trying to run and what the output of these
commands is.
(Note a purely C issue:
void getAccountInfo(char *result) {
result = "SUCCESSFUL ACCOUNT INFO RETURNED\0";
}
This doesn't return the string to the caller. The code is like "void
foo(int x) { x = 42; }", where the assignment to x has no effect at
all.)
A bientôt,
Armin.