SourceForge has been redesigned. Learn more.

'yytext' was not declared in this scope

  • AKHmetgaleev ILdar

    I can't compile Rev: 1200

    make  all-am
    make[4]: Entering directory `/home/ildar/src/pixie-svn/src/sdrc'
    g++ -DHAVE_CONFIG_H -I. -I../.. -I.. -I../ri    -O3 -pipe -mtune=amdfam10 -march=amdfam10 -m3dnow -mmmx -msse -msse2 -msse3 -msse4a -mfpmath=sse -fomit-frame-pointer -funsafe-math-optimizations -msseregparm -ffast-math -MT sl.o -MD -MP -MF .deps/sl.Tpo -c -o sl.o sl.cpp
    sl.y: In function 'void slerror(const char*)':
    sl.y:2858: error: 'yytext' was not declared in this scope
    make[4]: *** [sl.o] Error 1
    make[4]: Leaving directory `/home/ildar/src/pixie-svn/src/sdrc'

    gcc (Gentoo 4.3.2 p1.2) 4.3.2

    any suggestions?

    • Okan Arikan

      Okan Arikan - 2009-02-23


          Can you tell me which version of flex and bison?

          flex -v and bison -v should give you that information.



      • AKHmetgaleev ILdar

        flex 2.5.33
        bison (GNU Bison) 2.3

    • fro lee

      fro lee - 2009-03-11

      Getting a similar error under OS X trying to compile pixie from svn using terminal.  I have the same version of flex & bison.

      sl.y: In function ‘void slerror(const char*)’:
      sl.y:2858: error: ‘yytext’ was not declared in this scope
      make[3]: *** [sl.o] Error 1
      make[2]: *** [install] Error 2
      make[1]: *** [install-recursive] Error 1
      make: *** [install-recursive] Error 1

      Any further developments?

      • Okan Arikan

        Okan Arikan - 2009-03-12

            This is very weird, I just verified the trunk 1202 compiles on
                Flex: 2.5.35
                Bison: 2.4.1

                Flex: 2.5.34
                Bison: 2.3

                Flex: 2.5.35
                Bison: 2.3

            This seems to be a flex issue. Did you try upgrading to the latest version? Were you able to compile a previous revision?

            You can fix this problem by deleting lines 2858 to 2861 in sl.y. However I do not want to do this change before understanding what's going on.



        • AKHmetgaleev ILdar

          gentoo linux
          bison (GNU Bison) 2.4
          flex 2.5.35

          works fine

    • Roine Gustafsson

      The problem is that yytext is not defined. It's actually strange that it works on some compilers...
      This tiny patch adds 'yytext' as an extern and should have been in my patch from the beginning, sorry.
      I think accessing yytext outside of Lex is 'undefined', but it seems to work and it improves error context.

      --- src/sdrc/sl.y   (revision 1191)
      +++ src/sdrc/sl.y   (working copy)
      @@ -70,6 +70,7 @@
      #include   "opcodes.h"
      #include   "sdr.h"

      +extern char *yytext;
          void                yyerror(const char *);          // Forward definition for stupid yacc
          int                 yylex(void );                   // Forward definition for stupid yacc

  • Mike Giammatteo

    Mike Giammatteo - 2009-11-17

    Hello , I have the same issue 2.2.4 compiles but not 2.2.5 or 2.2.6 both fail with the yytext error . So my fix was to delet the lines 2858-2861 from in the sl.y in 2.2.6 making line 2858 sdr->error("Parse error\n"); hope that helps others. Jrabbit


Log in to post a comment.