Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ohNet Java bindings compilation failure
29-01-2016, 08:02 AM
Post: #1
ohNet Java bindings compilation failure
A recent change to the ohNet Java bindings (this commit) is causing a compilation failure for me on Microsoft Visual C++. In InitParams.c, the line

const char* hostName = (*aEnv)->GetStringUTFChars(aEnv, aHostName, NULL);

in the OhNetInitParamsSetDvEnableBonjour function (line 671) is misplaced. It should appear before the first assignment statement

aEnv = aEnv;
Find all posts by this user
29-01-2016, 12:11 PM
Post: #2
RE: ohNet Java bindings compilation failure
(29-01-2016 08:02 AM)simoncn Wrote:  A recent change to the ohNet Java bindings (this commit) is causing a compilation failure for me on Microsoft Visual C++. In InitParams.c, the line

const char* hostName = (*aEnv)->GetStringUTFChars(aEnv, aHostName, NULL);

in the OhNetInitParamsSetDvEnableBonjour function (line 671) is misplaced. It should appear before the first assignment statement

aEnv = aEnv;

The line
aEnv = aEnv;
was no longer required (it just suppresses a warning about an unused parameter and the commit you referenced started using that parameter). So, the fix was nice and easy - just remove the line. I've done this now.

Out of interest, what version of MSVC was warning about this? We're using 2013 which doesn't report any warnings here.
Find all posts by this user
29-01-2016, 03:31 PM
Post: #3
RE: ohNet Java bindings compilation failure
(29-01-2016 12:11 PM)simonc Wrote:  The line
aEnv = aEnv;
was no longer required (it just suppresses a warning about an unused parameter and the commit you referenced started using that parameter). So, the fix was nice and easy - just remove the line. I've done this now.

Out of interest, what version of MSVC was warning about this? We're using 2013 which doesn't report any warnings here.

Removing this self-assignment is fine for the reason that you stated. However, it is still necessary to move the line

const char* hostName = (*aEnv)->GetStringUTFChars(aEnv, aHostName, NULL);

before the line

aClass = aClass;

to prevent compilation errors with the compiler I am using. This compiler is:

Microsoft ® 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86

and is part of Visual Studio 2010.
Find all posts by this user
29-01-2016, 03:42 PM
Post: #4
RE: ohNet Java bindings compilation failure
(29-01-2016 03:31 PM)simoncn Wrote:  Removing this self-assignment is fine for the reason that you stated. However, it is still necessary to move the line

const char* hostName = (*aEnv)->GetStringUTFChars(aEnv, aHostName, NULL);

before the line

aClass = aClass;

to prevent compilation errors with the compiler I am using. This compiler is:

Microsoft ® 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86

and is part of Visual Studio 2010.

Oh, I see, the error is about declaring all variables at the start of a function for compilers that implement C89. I hadn't realised MSVC 2013 had moved beyond this. Its fixed now.
Find all posts by this user


Forum Jump: