Search code examples
flex-lexerlexlexical-analysis

lex : How to override YY_BUF_SIZE


According to the manual YY_BUF_SIZE is 16K and we need to override it. However, the manual does not specify how to override it, nor could I find any command line option for this. Can someone please indicate how to change this. In the generated source YY_BUF_SIZE is defined as follows:

#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
#endif

so there may be a way to override it before this.


Solution

  • In your own code, simply #define YY_BUF_SIZE to whatever value you want. As long as you compile your code so the compiler sees your definition first, the #ifndef guard will prevent the default value from being set.