pingu
pingu

Reputation: 8827

Passing a struct to a dynamically loaded dll

I have a dynamically loaded dll that has functions called on it, and i would like to pass it a struct. It is dynamically loaded as i do not know which version of the dll i will be using untill runtime.

Firstly, should i pass by value or reference?

Secondly, where do I declare this struct so it is available to both the dll and its caller (i assume it has to be available to both).

If i declare it in the same dll that accepts it as a parameter, then surly any potential user of the dll will have to statically link against the dll so it has access to the struct declaration, and this is what i originally wanted to avoid.

Upvotes: 1

Views: 2163

Answers (1)

Georg Fritzsche
Georg Fritzsche

Reputation: 98984

Firstly, should i pass by value or reference?

That depends, see e.g. this question.

Secondly, where do I declare this struct so it is available to both the dll and its caller

You declare it in a header file that both use. The struct is declared at compile-time, no linking against any library is needed for that.

Upvotes: 2

Related Questions