'snprintf': identifier not found

299 views
Skip to first unread message

Jamie Peabody

unread,
Nov 7, 2014, 2:09:21 PM11/7/14
to node...@googlegroups.com
Hi,

I am interested in trying out node-java, which looks really cool.  However, I get this error when compiling on Windows 7 using Visual Studio 12.0 C++ Express:
..\src\java.cpp(1055): error C3861: 'snprintf': identifier not found [G:\trunk\dev\projects\constellation\node_modules\java\build\nodejavabridge_bindings.vcxproj]

Any thoughts?

Jamie

Jim Lloyd

unread,
Nov 7, 2014, 3:58:11 PM11/7/14
to Jamie Peabody, node...@googlegroups.com
Looks like that's my fault. I introduced that code a few weeks back with PR 168, published as version 0.4.3. I currently don't have any way to test with Visual Studio. After a little googling, it seems like support for snprintf is weak. I'm only using it to convert an integer to a string, so perhaps I should just hack some simple function.

In the meantime, if you don't need Java 8 support, you can just use the previous version of the package, version 0.4.2.



--
You received this message because you are subscribed to the Google Groups "node-java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-java+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jim Lloyd

unread,
Nov 7, 2014, 4:46:16 PM11/7/14
to Jamie Peabody, node...@googlegroups.com
Jamie, it looks like maybe Microsoft Visual Studio would work if we used the function _snprintf instead of snprintf (just add a leading _). Can you try that out? Just edit src\java.cpp and include these three lines around line 1053 (just before the definition of int_to_string()):

#ifdef WIN32
  #define snprintf _snprintf
#endif

After editing that file, npm install should work. If it does, I can prepare the PR with that change.

Jim

Jamie Peabody

unread,
Nov 8, 2014, 4:50:13 AM11/8/14
to Jim Lloyd, node...@googlegroups.com
Hi Jim,

I used std::to_string instead.  Also changed to use <string> instead of <string.h> as the latter is for c functions.  It compiles for me.  I'm not really sure how to run the tests.

Jamie

Jamie Peabody

unread,
Nov 8, 2014, 5:18:31 AM11/8/14
to Jim Lloyd, node...@googlegroups.com
I gave up running the 'npm test' - it appears I need the JRE 6 rt.jar and don't really feel like installing it.  Also, the test8 was specific to mac, so I gave up there too.  That said, if I compiled the 'npm test' using Java 1.8, then the tests passed, save for this at the end:

*** ERROR: Lost reference to the dynamic proxy. You must maintain a reference in javascript land using ref() and unref(). (000000000032A100) ***
*** ERROR: Lost reference to the dynamic proxy. You must maintain a reference in javascript land using ref() and unref(). (000000000032A100) ***
*** ERROR: Lost reference to the dynamic proxy. You must maintain a reference in javascript land using ref() and unref(). (000000000032A100) ***

Jamie
Reply all
Reply to author
Forward
0 new messages