invalid directive: `%code'

Issue #10 resolved
Ataias Pereira Reis
created an issue

Hello, is this library supposed to work on Mac OS X? I did the following:

$ hg clone ssh://hg@bitbucket.org/tunnuz/json
$ mkdir build
$ cd build
$ cmake ..

At this point, I had the output from CMake:

 -- The C compiler identification is Clang 5.1.0
 -- The CXX compiler identification is Clang 5.1.0
 -- Check for working C compiler: /usr/bin/cc
 -- Check for working C compiler: /usr/bin/cc -- works
 -- Detecting C compiler ABI info
 -- Detecting C compiler ABI info - done
 -- Check for working CXX compiler: /usr/bin/c++
 -- Check for working CXX compiler: /usr/bin/c++ -- works
 -- Detecting CXX compiler ABI info
 -- Detecting CXX compiler ABI info - done
 -- Found BISON: /usr/bin/bison (found version "2.3") 
 -- Found FLEX: /usr/bin/flex (found version "2.5.35") 
 -- Configuring done
 -- Generating done
 -- Build files have been written to: /Users/ataias/Documents/json/build

Then

$ make
/Users/ataias/Documents/json/json.y:20.1-5: invalid directive: `%code'
/Users/ataias/Documents/json/json.y:20.7-14: syntax error, unexpected identifier
make[2]: *** [../json.tab.cc] Error 1
make[1]: *** [CMakeFiles/json.dir/all] Error 2
make: *** [all] Error 2

Is this a known issue? Has anyone succeed to compile on Mac? What about required libraries? I didn't see any requirement to install when I looked in the README.

Comments (5)

  1. Tommaso Urli repo owner

    Hello Ataias. There are no additional requirements except for Flex and Bison, and most of the development of JSON++ happened on a MacBook. I will try to look into this problem as soon as possible, however I would suggest to try a newer version of Bison, mine is (GNU Bison) 2.7.12-4996 (yours seems a bit outdated).

  2. Ataias Pereira Reis reporter

    Alright, I installed a newer bison:

        $$ cmake ..
    -- The C compiler identification is Clang 5.1.0
    -- The CXX compiler identification is Clang 5.1.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Found BISON: /usr/local/Cellar/bison/3.0.2/bin/bison (found version "3.0.2") 
    -- Found FLEX: /usr/local/Cellar/flex/2.5.37/bin/flex (found version "2.5.37") 
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/ataias/Documents/json/build
    

    It built, but I need to go to work now and I will test it later. Anyway, I would like to ask why so many warning in the building process:

    Scanning dependencies of target json
    [ 16%] Building CXX object CMakeFiles/json.dir/json_st.cc.o
    [ 33%] Building CXX object CMakeFiles/json.dir/json.tab.cc.o
    [ 50%] Building CXX object CMakeFiles/json.dir/lex.yy.cc.o
    /Users/ataias/Documents/json/lex.yy.cc:688:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register yy_state_type yy_current_state;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:689:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register char *yy_cp, *yy_bp;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:689:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register char *yy_cp, *yy_bp;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:690:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register int yy_act;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:739:4: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
                            register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
                            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1013:6: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1014:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register char *source = (yytext_ptr);
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1015:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register int number_to_move, i;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1015:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register int number_to_move, i;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1147:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register yy_state_type yy_current_state;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1148:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register char *yy_cp;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1154:3: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
                    register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
                    ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1179:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register int yy_is_jam;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1180:6: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register char *yy_cp = (yy_c_buf_p);
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1182:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register YY_CHAR yy_c = 1;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1202:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
            register char *yy_cp;
            ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1212:3: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
                    register yy_size_t number_to_move = (yy_n_chars) + 2;
                    ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1213:3: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
                    register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
                    ^~~~~~~~~
    /Users/ataias/Documents/json/lex.yy.cc:1215:3: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
                    register char *source =
                    ^~~~~~~~~
    19 warnings generated.
    Linking CXX static library libjson.a
    [ 83%] Built target json
    Scanning dependencies of target test
    [100%] Building CXX object CMakeFiles/test.dir/test.cc.o
    Linking CXX executable test
    [100%] Built target test
    

    Maybe you could add in the README a minimum version of Bison to be used. Oh, I don't have Macports so I installed with Homebrew.

    Thank you and regards,

  3. Tommaso Urli repo owner

    The warnings are caused by some code which is automatically generated by Flex and Bison, I guess it's just a matter of standards (looks like register has become deprecated at some time).

    As for the minimum version of Bison, I think that I can specify it in the CMakeList.txt, that should raise an error if the version is too low. Thanks for the advice.

    T

  4. Log in to comment