June 07, 2012
On 6/7/12, Kagamin <spam@here.lot> wrote:
> You didn't define the variable.

Aah, I see what's going on. See, I was using this in the context of wrapping existing C++ libs. Since I was writing a small test-case for wrapping a static field I made a header file with a static field declaration but no .cpp implementation files (except the wrapper). I didn't know I had to either have an initializer in the header or have a .cpp file with the definition.

For actual C++ libs the definition of a static field is somewhere in an existing cpp file, so I don't have to re-define the static field when wrapping (otherwise I'd probably get collisions or multiple independent variables).
June 08, 2012
On Thursday, 7 June 2012 at 23:58:21 UTC, Andrej Mitrovic wrote:
> I
> didn't know I had to either have an initializer in the header or have
> a .cpp file with the definition.

Well, I'm not a C++ pro, but I won't recommend to place initializer in the header. That sounds odd. What would it mean? I guess, it will mean definition, so chances are it's not what you want. Initializers belong to definitions, and definitions belong to .cpp, that's how it usually works unless you know for sure you want something else. Bindings are just fine with declarations alone + support code.
June 08, 2012
On 6/8/12, Kagamin <spam@here.lot> wrote:
> Well, I'm not a C++ pro, but I won't recommend to place initializer in the header. That sounds odd. What would it mean? I guess, it will mean definition, so chances are it's not what you want. Initializers belong to definitions, and definitions belong to .cpp, that's how it usually works unless you know for sure you want something else. Bindings are just fine with declarations alone + support code.
>

Yeah I thought they might appear in an existing library in a header file but it seems they're in the definition file. Thanks for your help.
1 2
Next ›   Last »