I'm working on the node.js module in Visual Studio and have the following 
file structure:

load.h

    #include <string>
    #include <v8.h>

    void property_guard(v8::Local<v8::Object> obj, v8::Local<v8::String> 
name, const std::string path);

load.cpp

    #include "load.h"

    void property_guard(v8::Local<v8::Object> obj, v8::Local<v8::String> 
name, const std::string path) {
        if (!obj->Has(name)) {
            throw path + " does not exist";
        }
    }

main.cpp

    #include <string>
    #include <node.h>
    #include <v8.h>
    #include "load.h"

    void integer_type_guard(v8::Local<v8::Value> obj, const std::string 
path) {
        if (!obj->IsInt32()) {
            throw path + " is not an integer";
        }
    }

    int get_int_property(v8::Local<v8::Object> obj, v8::Local<v8::String> 
name, const std::string path) {
        property_guard(obj, name, path);
        v8::Local<v8::Value> value = obj->Get(name);
        integer_type_guard(value, path);
        return value->Int32Value();
    }


I expect that the structure is correct, but I get an error in Visual Studio 
and similar when I compile the project with node-gyp:

    error LNK2005: "public: class v8::Object * __cdecl v8::Handle<class 
v8::Object>::operator->(void)const " 
(??C?$Handle@VObject@v8@@@v8@@QEBAPEAVObject@1@XZ) already defined in 
node.lib(node.exe) C:\...\load.obj
    error LNK1169: one or more multiply defined symbols found 
C:\...\Test1.dll

Removing the node.h from the main.cpp includes removes the error (I need it 
to register the module). Moving the property_guard method to main.cpp also 
solves the issue.

What is the correct way of moving declaration to other file in this case?

My environment:

* Visual Studio 2012
* node.js 0.10.12 x64

Thank you,
Alex

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to