ZooKeeper
  1. ZooKeeper
  2. ZOOKEEPER-1679

c client: use -Wdeclaration-after-statement

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.4.5
    • Fix Version/s: 3.5.0
    • Component/s: c client
    • Labels:
      None

      Description

      Visual studio still doesn't support c99.

      --Michi

      1. ZOOKEEPER-1679.patch
        3 kB
        Michi Mutsuzaki

        Activity

        Hide
        Michi Mutsuzaki added a comment -

        Visual studio complains if a variable declaration is found after a statement. This patch adds -Wdeclaration-after-statement option to the Makefile to catch the error at compile time when using gcc.

        It also fixes a minor compilation error on windows (use _strtoui64 instead of strtoull).

        I tested the patch with visual studio 2008. This patch should fix the current windows build failure.

        Show
        Michi Mutsuzaki added a comment - Visual studio complains if a variable declaration is found after a statement. This patch adds -Wdeclaration-after-statement option to the Makefile to catch the error at compile time when using gcc. It also fixes a minor compilation error on windows (use _strtoui64 instead of strtoull). I tested the patch with visual studio 2008. This patch should fix the current windows build failure.
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12576154/ZOOKEEPER-1679.patch
        against trunk revision 1462141.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 1 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1441//testReport/
        Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1441//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1441//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12576154/ZOOKEEPER-1679.patch against trunk revision 1462141. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 1 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1441//testReport/ Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1441//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1441//console This message is automatically generated.
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12576154/ZOOKEEPER-1679.patch
        against trunk revision 1463329.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 1 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1446//testReport/
        Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1446//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1446//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12576154/ZOOKEEPER-1679.patch against trunk revision 1463329. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 1 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1446//testReport/ Findbugs warnings: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1446//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/1446//console This message is automatically generated.
        Hide
        Flavio Junqueira added a comment -

        Hi Michi,

        I have tried your patch with visual studio 2010 and 2012. It fails to build on both and here is the output:

        1>------ Build started: Project: zookeeper, Configuration: Debug Win32 ------
        1>Build started 17/06/2013 19:14:43.
        1>InitializeBuildStatus:
        1>  Touching "Debug\zookeeper.unsuccessfulbuild".
        1>ClCompile:
        1>  zk_log.c
        1>src\c\include\winconfig.h(187): warning C4005: 'EWOULDBLOCK' : macro redefinition
        1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\errno.h(132) : see previous definition of 'EWOULDBLOCK'
        1>src\c\include\winconfig.h(188): warning C4005: 'EINPROGRESS' : macro redefinition
        1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\errno.h(104) : see previous definition of 'EINPROGRESS'
        1>src\c\src\zk_log.c(120): warning C4996: '_snprintf': This function or variable may be unsafe. Consider using _snprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(363) : see declaration of '_snprintf'
        1>src\c\src\zk_log.c(138): error C2143: syntax error : missing ';' before 'type'
        1>src\c\src\zk_log.c(140): error C2065: 'pid' : undeclared identifier
        1>src\c\src\zk_log.c(142): error C2065: 'pid' : undeclared identifier
        1>src\c\src\zk_log.c(146): error C2143: syntax error : missing ';' before 'type'
        1>src\c\src\zk_log.c(147): error C2143: syntax error : missing ';' before 'const'
        1>src\c\src\zk_log.c(160): error C2143: syntax error : missing ';' before 'type'
        1>src\c\src\zk_log.c(165): error C2143: syntax error : missing ';' before 'type'
        1>src\c\src\zk_log.c(171): error C2275: 'va_list' : illegal use of this type as an expression
        1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vadefs.h(57) : see declaration of 'va_list'
        1>src\c\src\zk_log.c(171): error C2146: syntax error : missing ';' before identifier 'va'
        1>src\c\src\zk_log.c(171): error C2065: 'va' : undeclared identifier
        1>src\c\src\zk_log.c(172): error C2065: 'va' : undeclared identifier
        1>src\c\src\zk_log.c(172): warning C4047: '=' : 'int' differs in levels of indirection from 'va_list'
        1>src\c\src\zk_log.c(173): error C2065: 'ofs' : undeclared identifier
        1>src\c\src\zk_log.c(173): error C2065: 'ofs' : undeclared identifier
        1>src\c\src\zk_log.c(173): error C2065: 'va' : undeclared identifier
        1>src\c\src\zk_log.c(173): warning C4047: 'function' : 'va_list' differs in levels of indirection from 'int'
        1>src\c\src\zk_log.c(173): warning C4024: 'vsnprintf' : different types for formal and actual parameter 4
        1>src\c\src\zk_log.c(174): error C2065: 'va' : undeclared identifier
        1>src\c\src\zk_log.c(174): warning C4047: '=' : 'int' differs in levels of indirection from 'va_list'
        1>  mt_adaptor.c
        1>src\c\include\winconfig.h(187): warning C4005: 'EWOULDBLOCK' : macro redefinition
        1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\errno.h(132) : see previous definition of 'EWOULDBLOCK'
        1>src\c\include\winconfig.h(188): warning C4005: 'EINPROGRESS' : macro redefinition
        1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\errno.h(104) : see previous definition of 'EINPROGRESS'
        1>src\c\src\mt_adaptor.c(119): error C2065: 'zh' : undeclared identifier
        1>src\c\src\mt_adaptor.c(119): warning C4047: 'function' : 'const zhandle_t *' differs in levels of indirection from 'int'
        1>src\c\src\mt_adaptor.c(119): warning C4024: 'zoo_get_log_callback' : different types for formal and actual parameter 1
        1>src\c\src\mt_adaptor.c(134): error C2065: 'zh' : undeclared identifier
        1>src\c\src\mt_adaptor.c(134): warning C4047: 'function' : 'const zhandle_t *' differs in levels of indirection from 'int'
        1>src\c\src\mt_adaptor.c(134): warning C4024: 'zoo_get_log_callback' : different types for formal and actual parameter 1
        1>src\c\src\mt_adaptor.c(498): warning C4244: '=' : conversion from 'time_t' to 'int32_t', possible loss of data
        1>  Generating Code...
        1>
        1>Build FAILED.
        1>
        1>Time Elapsed 00:00:00.39
        ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
        

        Any insight here?

        Show
        Flavio Junqueira added a comment - Hi Michi, I have tried your patch with visual studio 2010 and 2012. It fails to build on both and here is the output: 1>------ Build started: Project: zookeeper, Configuration: Debug Win32 ------ 1>Build started 17/06/2013 19:14:43. 1>InitializeBuildStatus: 1> Touching "Debug\zookeeper.unsuccessfulbuild". 1>ClCompile: 1> zk_log.c 1>src\c\include\winconfig.h(187): warning C4005: 'EWOULDBLOCK' : macro redefinition 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\errno.h(132) : see previous definition of 'EWOULDBLOCK' 1>src\c\include\winconfig.h(188): warning C4005: 'EINPROGRESS' : macro redefinition 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\errno.h(104) : see previous definition of 'EINPROGRESS' 1>src\c\src\zk_log.c(120): warning C4996: '_snprintf': This function or variable may be unsafe. Consider using _snprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(363) : see declaration of '_snprintf' 1>src\c\src\zk_log.c(138): error C2143: syntax error : missing ';' before 'type' 1>src\c\src\zk_log.c(140): error C2065: 'pid' : undeclared identifier 1>src\c\src\zk_log.c(142): error C2065: 'pid' : undeclared identifier 1>src\c\src\zk_log.c(146): error C2143: syntax error : missing ';' before 'type' 1>src\c\src\zk_log.c(147): error C2143: syntax error : missing ';' before 'const' 1>src\c\src\zk_log.c(160): error C2143: syntax error : missing ';' before 'type' 1>src\c\src\zk_log.c(165): error C2143: syntax error : missing ';' before 'type' 1>src\c\src\zk_log.c(171): error C2275: 'va_list' : illegal use of this type as an expression 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vadefs.h(57) : see declaration of 'va_list' 1>src\c\src\zk_log.c(171): error C2146: syntax error : missing ';' before identifier 'va' 1>src\c\src\zk_log.c(171): error C2065: 'va' : undeclared identifier 1>src\c\src\zk_log.c(172): error C2065: 'va' : undeclared identifier 1>src\c\src\zk_log.c(172): warning C4047: '=' : 'int' differs in levels of indirection from 'va_list' 1>src\c\src\zk_log.c(173): error C2065: 'ofs' : undeclared identifier 1>src\c\src\zk_log.c(173): error C2065: 'ofs' : undeclared identifier 1>src\c\src\zk_log.c(173): error C2065: 'va' : undeclared identifier 1>src\c\src\zk_log.c(173): warning C4047: 'function' : 'va_list' differs in levels of indirection from 'int' 1>src\c\src\zk_log.c(173): warning C4024: 'vsnprintf' : different types for formal and actual parameter 4 1>src\c\src\zk_log.c(174): error C2065: 'va' : undeclared identifier 1>src\c\src\zk_log.c(174): warning C4047: '=' : 'int' differs in levels of indirection from 'va_list' 1> mt_adaptor.c 1>src\c\include\winconfig.h(187): warning C4005: 'EWOULDBLOCK' : macro redefinition 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\errno.h(132) : see previous definition of 'EWOULDBLOCK' 1>src\c\include\winconfig.h(188): warning C4005: 'EINPROGRESS' : macro redefinition 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\errno.h(104) : see previous definition of 'EINPROGRESS' 1>src\c\src\mt_adaptor.c(119): error C2065: 'zh' : undeclared identifier 1>src\c\src\mt_adaptor.c(119): warning C4047: 'function' : 'const zhandle_t *' differs in levels of indirection from 'int' 1>src\c\src\mt_adaptor.c(119): warning C4024: 'zoo_get_log_callback' : different types for formal and actual parameter 1 1>src\c\src\mt_adaptor.c(134): error C2065: 'zh' : undeclared identifier 1>src\c\src\mt_adaptor.c(134): warning C4047: 'function' : 'const zhandle_t *' differs in levels of indirection from 'int' 1>src\c\src\mt_adaptor.c(134): warning C4024: 'zoo_get_log_callback' : different types for formal and actual parameter 1 1>src\c\src\mt_adaptor.c(498): warning C4244: '=' : conversion from 'time_t' to 'int32_t', possible loss of data 1> Generating Code... 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:00.39 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Any insight here?
        Hide
        Flavio Junqueira added a comment -

        +1, works for me.

        Show
        Flavio Junqueira added a comment - +1, works for me.
        Hide
        Flavio Junqueira added a comment -

        Committed revision 1516126.

        Show
        Flavio Junqueira added a comment - Committed revision 1516126.
        Hide
        Hudson added a comment -

        SUCCESS: Integrated in ZooKeeper-trunk #2030 (See https://builds.apache.org/job/ZooKeeper-trunk/2030/)
        ZOOKEEPER-1679. c client: use -Wdeclaration-after-statement (michi via fpj) (fpj: http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1516126)

        • /zookeeper/trunk/CHANGES.txt
        • /zookeeper/trunk/src/c/Makefile.am
        • /zookeeper/trunk/src/c/src/cli.c
        • /zookeeper/trunk/src/c/src/zookeeper.c
        Show
        Hudson added a comment - SUCCESS: Integrated in ZooKeeper-trunk #2030 (See https://builds.apache.org/job/ZooKeeper-trunk/2030/ ) ZOOKEEPER-1679 . c client: use -Wdeclaration-after-statement (michi via fpj) (fpj: http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1516126 ) /zookeeper/trunk/CHANGES.txt /zookeeper/trunk/src/c/Makefile.am /zookeeper/trunk/src/c/src/cli.c /zookeeper/trunk/src/c/src/zookeeper.c

          People

          • Assignee:
            Michi Mutsuzaki
            Reporter:
            Michi Mutsuzaki
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development