From: MARK CALLAGHAN Date: January 29 2009 5:02pm Subject: Re: STL, C++, Mysql Development? List-Archive: http://lists.mysql.com/internals/36205 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Thu, Jan 29, 2009 at 8:10 AM, Patrick Lau wrote: > Hi all, > > Is it possible to use STL for mysql development? I tried to use > std::map, but it fails everytime during compilation... > > Here some code snippets: > > [dejavu_router.h] > > #ifndef ROUTER_H_ > #define ROUTER_H_ > > #include > #include > > //using namespace std; > > class Dejavu_Router > { > private: > std::map freq; > std::string key; > public: > Dejavu_Router(){ > int b = 245; > key = "hallo"; > freq[key]=b; > } > int test_get_freq(std::string st); > }; > > #endif /*ROUTER_H_*/ > > Compiling error message: > > In file included from /usr/include/c++/4.3/bits/stl_tree.h:67, > from /usr/include/c++/4.3/map:65, > from dejavu_router.h:4, > from dejavu_fsm.h:5, > from mysql_priv.h:43, > from ha_ndbcluster.cc:26: > /usr/include/c++/4.3/bits/stl_algobase.h:232:56: error: macro "min" > passed 3 arguments, but takes just 2 > /usr/include/c++/4.3/bits/stl_algobase.h:252:56: error: macro "max" > passed 3 arguments, but takes just 2 > ... > In file included from /usr/include/c++/4.3/bits/stl_tree.h:67, > from /usr/include/c++/4.3/map:65, > from dejavu_router.h:4, > from dejavu_fsm.h:5, > from mysql_priv.h:43, > from ha_ndbcluster.cc:26: > /usr/include/c++/4.3/bits/stl_algobase.h:188: error: expected > unqualified-id before 'const' > /usr/include/c++/4.3/bits/stl_algobase.h:188: error: expected `)' before 'const' > /usr/include/c++/4.3/bits/stl_algobase.h:188: error: expected `)' before 'const' > /usr/include/c++/4.3/bits/stl_algobase.h:188: error: expected > initializer before 'const' > /usr/include/c++/4.3/bits/stl_algobase.h:210: error: expected > unqualified-id before 'const' > /usr/include/c++/4.3/bits/stl_algobase.h:210: error: expected `)' before 'const' > /usr/include/c++/4.3/bits/stl_algobase.h:210: error: expected `)' before 'const' > /usr/include/c++/4.3/bits/stl_algobase.h:210: error: expected > initializer before 'const' > /usr/include/c++/4.3/bits/stl_algobase.h:232: error: function > definition does not declare parameters > /usr/include/c++/4.3/bits/stl_algobase.h:252: error: function > definition does not declare parameters > /usr/include/c++/4.3/bits/stl_algobase.h: In static member function > 'static bool std::__lexicographical_compare::__lc(const _Tp*, > const _Tp*, const _Up*, const _Up*)': > /usr/include/c++/4.3/bits/stl_algobase.h:904: error: expected > unqualified-id before '(' token > .... > > dejavu_fsm.h does not use any STL stuff. Compilation works without > dejavu_router.h... > > I'm using mysql-6.0.3-alpha, gcc 4.3.2, ubuntu 8.10.... > > Thanks for your help in advance... > Regards, > Patrick > > -- > MySQL Internals Mailing List > For list archives: http://lists.mysql.com/internals > To unsubscribe: http://lists.mysql.com/internals?unsub=mdcallag@stripped > > I have done this with gcc 4.2 but only for private code. Your header files are included by traditional MySQL source files (mysql_priv.h) and that is guaranteed not to work. For example, try adding '#include ' to sql_parse.cc and recompile it. That works when it is the first include but probably not in any other case. The drizzle branch of MySQL is the best place to try to use STL with MySQL. -- Mark Callaghan mdcallag@stripped