BenHanson / parsertl14

C++14 version of parsertl
32 stars 4 forks source link

Error: 'unsigned char' is not a class, struct, or union type (Compilation error with gcc 11.2.0 under MSYS2) #4

Closed cwebdesign closed 2 years ago

cwebdesign commented 2 years ago
g++ -o test main.cpp In file included from main.cpp:4: include/parsertl/generator.hpp: In instantiation of 'class parsertl::basic_generator<parsertl::basic_rules<char, unsigned char>, unsigned char>': main.cpp:845:13: required from here include/parsertl/generator.hpp:488:15: error: 'unsigned char' is not a class, struct, or union type 488 using entry = typename sm::entry; ^~~~~ main.cpp: In function 'void search_header()': main.cpp:845:44: error: cannot convert 'gstate_machine' {aka 'parsertl::basic_state_machine'} to 'unsigned char&' 845 ggenerator::build(grules, gsm); ^~~~
gstate_machine {aka parsertl::basic_state_machine}

In file included from main.cpp:4: include/parsertl/generator.hpp:52:46: note: initializing argument 2 of 'static void parsertl::basic_generator<rules, sm, id_type>::build(rules&, sm&, std::string) [with rules = parsertl::basic_rules<char, unsigned char>; sm = unsigned char; id_type = short unsigned int; std::string = std::__cxx11::basicstring]' 52 | static void build(rules& rules, sm& sm_, std::string warnings_ = 0) | ~~^ include/parsertl/generator.hpp: In instantiation of 'static void parsertl::basic_generator<rules, sm, id_type>::build(rules&, sm&, std::string*) [with rules = parsertl::basic_rules<char, unsigned char>; sm = unsigned char; id_type = short unsigned int; std::string = std::__cxx11::basicstring]': main.cpp:845:15: required from here include/parsertl/generator.hpp:67:17: error: request for member 'clear' in 'sm', which is of non-class type 'unsigned char' 67 | sm_.clear(); | ~~^~~ In file included from L:/msys64/mingw64/include/c++/11.2.0/cassert:44, from include/parsertl/../../../lexertl14/include/lexertl/lookup.hpp:9, from include/parsertl/../../../lexertl14/include/lexertl/iterator.hpp:11, from include/parsertl/rules.hpp:13, from include/parsertl/debug.hpp:11, from main.cpp:3: include/parsertl/generator.hpp:84:45: error: request for member 'columns' in 'sm', which is of non-class type 'unsigned char' 84 | assert(static_cast(sm_.columns - 1) == sm._columns - 1); | ~~^~ include/parsertl/generator.hpp:84:66: error: request for member 'columns' in 'sm', which is of non-class type 'unsigned char' 84 | assert(static_cast(sm_.columns - 1) == sm._columns - 1); | ~~^~ include/parsertl/generator.hpp:85:45: error: request for member 'rows' in 'sm', which is of non-class type 'unsigned char' 85 | assert(static_cast(sm_.rows - 1) == sm._rows - 1); | ~~^~~ include/parsertl/generator.hpp:85:63: error: request for member 'rows' in 'sm', which is of non-class type 'unsigned char' 85 | assert(static_cast(sm_.rows - 1) == sm._rows - 1); | ~~^~~ In file included from main.cpp:4: include/parsertl/generator.hpp:87:17: error: request for member 'captures' in 'sm', which is of non-class type 'unsigned char' 87 | sm_.captures = rules.captures(); | ~~^~~

BenHanson commented 2 years ago

Change the ggenerator line to:

using ggenerator = parsertl::basic_generator<grules, gstate_machine, unsigned char>;