List:Internals« Previous MessageNext Message »
From:MARK CALLAGHAN Date:January 29 2009 5:02pm
Subject:Re: STL, C++, Mysql Development?
View as plain text  
On Thu, Jan 29, 2009 at 8:10 AM, Patrick Lau <patro02@stripped> 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 <map>
> #include <string>
>
> //using namespace std;
>
> class Dejavu_Router
> {
> private:
>        std::map<std::string, int> 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<true>::__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=1
>
>

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
<map>' 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
Thread
STL, C++, Mysql Development?Patrick Lau29 Jan
  • Re: STL, C++, Mysql Development?MARK CALLAGHAN29 Jan
  • Re: STL, C++, Mysql Development?Chad MILLER29 Jan
    • Re: Re: STL, C++, Mysql Development?Eric Prud'hommeaux29 Jan
      • Re: STL, C++, Mysql Development?Brian Aker29 Jan
        • Re: STL, C++, Mysql Development?Kesava Poyyale30 Jan
          • Re: STL, C++, Mysql Development?Patrick Lau30 Jan
            • Re: STL, C++, Mysql Development?Vladimir Shebordaev31 Jan