Compilation problem :Regex

Hello All, When I try to use regex with boost.multiindex I got the following compilation error. But when I indipendently compile multiindex package and regex package both compiles without any error. What is the problem? Can anyone please help me to getout of this Error dump: D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/regbase.hpp(125) : error C2955: 'collate' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\locale(67) : see declaration of 'collate' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(32) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(36) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(40) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(44) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(48) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/regbase.hpp(125) : error C2955: 'collate' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\locale(67) : see declaration of 'collate' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(32) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(36) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(40) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(44) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\BOOST\INCLUDE\BOOST-1_33_1\boost/regex/v4/perl_matcher.hpp(48) : error C2955: 'map' : use of class template requires template argument list C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map' D:\MYPROJECTS\BRIGHTCLOUD AGENT\URLNORMALIZATION\CDNList.h(18) : warning C4251: 'CDNVector' : class 'std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<cha Best Regards Mahesh Karanth --------------------------------- Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

When I try to use regex with boost.multiindex I got the following compilation error. But when I indipendently compile multiindex package and regex package both compiles without any error.
What is the problem? Can anyone please help me to getout of this
You must be using VC7 :-) The problem occurs if you do something like this: #include <locale> using namespace std; #include <boost/regex.hpp> It's a bug in the compiler and there is no workaround, except, don't put a "using namespace std;" statement before including the regex header - or include it before any header that does that. I'm at a loss as to why multi-index should trigger this problem, I hope it doesn't include global using statements like that. But either way, try including the regex header first and see if that fixes things. John.

Unfortunately I am using 'using namespace std;' after all the include statements only. And I am using VC 6 I think I should tell you how I have creted my workspace I have a workspace in which a) 'Win32 console application' b)'Win32 Dinamic Link Library' (This project uses Boost.multi index) c)'Win32 Dinamic Link Library (This project uses Boost.Regex). I have used both b) and c) dll's in main (Win32 console application). Class hirarchy is as follows WorkSpace -> main files , multiindex files , regex files in the main I am calling the methods of multiindex and regex. Best Regards Mahesh Karanth John Maddock <john@johnmaddock.co.uk> wrote: > When I try to use regex with boost.multiindex I got the following
compilation error. But when I indipendently compile multiindex package and regex package both compiles without any error.
What is the problem? Can anyone please help me to getout of this
You must be using VC7 :-) The problem occurs if you do something like this: #include using namespace std; #include It's a bug in the compiler and there is no workaround, except, don't put a "using namespace std;" statement before including the regex header - or include it before any header that does that. I'm at a loss as to why multi-index should trigger this problem, I hope it doesn't include global using statements like that. But either way, try including the regex header first and see if that fixes things. John. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost --------------------------------- How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.

Hello Mahesh, mahesh karanth ha escrito:
Unfortunately I am using 'using namespace std;' after all the include statements only.
And I am using VC 6
I think I should tell you how I have creted my workspace
I have a workspace in which a) 'Win32 console application' b)'Win32 Dinamic Link Library' (This project uses Boost.multi index) c)'Win32 Dinamic Link Library (This project uses Boost.Regex).
I have used both b) and c) dll's in main (Win32 console application).
Class hirarchy is as follows
WorkSpace -> main files , multiindex files , regex files
Which multi_index files? Boost.MultiIndex is a header only library. When you say "But when I indipendently compile multiindex package and regex package both compiles without any error." what do you mean by compiling multiindex package? Could you describe what is this process you do in more detail?
in the main I am calling the methods of multiindex and regex.
Maybe can you post the file of yours where the compile error shows? If you can't for confidentiality reasons, you can either post privately of at least send the includes part. I tend to think, along with John, you're implicitly issuing a using directive, maybe in some of your headers. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

1.URLHandler class which uses Boost.Regex #ifndef _URLHANDLER_ #define _URLHANDLER_ #if !defined(NDEBUG) #endif //#include <boost/regex/v4/regex.hpp> #include <boost/regex.hpp> #include <stdio.h> #include <iostream> #include <cctype> #include <math.h> #include <fstream> #include <string> using namespace boost; using namespace std; #define DECIMAL 1 #define NORMAL_URL 4 #define HTTP 2 #define HTTPS 1 #define FTP 3 #define MALFORMEDURL 403 const string URLSYNTAXREGEX = "((https?|ftp)://)?(([a-zA-Z0-9-]+[.]{1}[a-zA-Z0-9]+)+([:]{1}((0[0-7]+)|(0[xX][0-9a-fA-F]+)|([0-9]+))){0,1})([?/][-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?"; const string DECIMALREGEX = "((0|[1-9]{1}[0-9]{0,2})[.]{1}(0|[1-9]{1}[0-9]{0,2})[.]{1}(0|[1-9]{1}[0-9]{0,2})[.]{1}(0|[1-9]{1}[0-9]{0,2}))([:]{1}((01?[0-7]{1,5})|(0[xX][0-9a-fA-F]{1,4})|(0|[1-9][0-9]{0,4}))){0,1}(/[-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?"; const string VALIDURLSYNTAXREGEX ="(([-a-zA-Z0-9.]+[.]+[-a-zA-Z]+)([:]{1}((01?[0-7]{1,5})|(0[xX][0-9a-fA-F]{1,4})|([1-9][0-9]{0,4}))){0,1})([?/][-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?"; const string VALIDIPREGEX="((0[0-7]{1,3})|(0[xX][0-9a-fA-F]{1,2})|(0|[1-9]{1}[0-9]{0,2}))[.]{1}((0[0-7]{1,3})|(0[xX][0-9a-fA-F]{1,2})|(0|[1-9]{1}[0-9]{0,2}))[.]{1}((0[0-7]{1,3})|(0[xX][0-9a-fA-F]{1,2})|(0|[1-9]{1}[0-9]{0,2}))[.]{1}((0[0-7]{1,3})|(0[xX][0-9a-fA-F]{1,2})|(0|[1-9]{1}[0-9]{0,2}))[:]{0,1}((01?[0-7]{1,5})|(0[xX][0-9a-fA-F]{1,4})|(0|[1-9]{1}[0-9]{0,4})?)(/[-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?"; const string URL="0"; const string IP="1"; static bool isPort; #define URLNORMALIZATION_ImportState __declspec( dllexport ) class URLNORMALIZATION_ImportState URLHandler { bool isDecimal(string); bool isCDN(string,string&); bool EvaluateRegex(const string,string); int GetPortNumber(string&); int ConvertHexToDecimal(string); int ConvertOctalToDecimal(string); int GetDecimalIp(string,string&); string decodePercentageTraces(string); string Truncatelevels(string); string GetType(string); void ToLower(string&); void removeProtocol(string&); public: URLHandler(); virtual ~URLHandler(); int validateURL(string,string&,string&); }; #endif 2.CacheStore class which uses Boost.multiindex #ifndef _CACHESTORE_H_ #define _CACHESTORE_H_ //#define NDEBUG #if !defined(NDEBUG) #define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING #define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE #endif #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/ordered_index.hpp> #include <algorithm> #include <iostream> #include <iterator> #include <string> #include <time.h> #include <vector> //#include <semaphore.h> using boost::multi_index_container; using namespace boost::multi_index; using namespace std; #define CACHEMANAGER_ImportState __declspec( dllexport ) class CACHEMANAGER_ImportState Cache { public: std::string url; std::string category; int criticality; long timeStamp; int frequency; Cache(){} Cache(string url_,string category_,int criticality_,int frequency_,long timeStamp_) { url=url_; category=category_; criticality=criticality_; timeStamp=timeStamp_; frequency=frequency_; } }; struct TAG_FREQUENCY{}; struct TAG_URL{}; struct TAG_CRITICALITY{}; struct TAG_TIMESTAMP{}; typedef multi_index_container < Cache, indexed_by < hashed_unique<tag<TAG_URL>,BOOST_MULTI_INDEX_MEMBER(Cache,std::string,url)> ,ordered_non_unique<tag<TAG_FREQUENCY>,BOOST_MULTI_INDEX_MEMBER(Cache,int,frequency)> ,ordered_non_unique<tag<TAG_CRITICALITY>,BOOST_MULTI_INDEX_MEMBER(Cache,int,criticality)> ,ordered_non_unique<tag<TAG_TIMESTAMP>,BOOST_MULTI_INDEX_MEMBER(Cache,long,timeStamp)> >
cache_set;
class CACHEMANAGER_ImportState CacheStore { private: //pthread_mutex_t getLock; //pthread_mutex_t insertLock; cache_set cacheSet; public: /*const static int NON_CRITICAL; const static int CRITICAL;*/ void insert(Cache cacheObj); int getCache(string url,Cache& cache_obj); void updateFrequency(string url);//Always increment frquency by one void updateCategory(string url,string category); void updateCache(string url,string category,int frequency,int criticality,long timeStamp); int getSize(); int getNonCriticalCacheSize(); int remove(int count=1); void display(); std::vector<string> getAllEntry(); void removeElapsedEntries(); CacheStore() { //cacheSet=new cache_set(); //pthread_mutex_init(&(getLock),NULL); //pthread_mutex_init(&(insertLock),NULL); } CacheStore(const CacheStore& obj){} //copy constructure CacheStore& operator=(const CacheStore& ) { return *this; } //assignment op overloading }; #endif //_CACHESTORE_H_ Both are of diffrent DLL's. I am using the above two class inside the main() which looks as follows #include "URLHandler.h" #include "CacheStore.h" #include <string> using namespace std; void main() { .... .... ..... } When I compile 'URLHandler' and 'CacheStore' independently both will compile without any errors. But when integrated with main() gives the compilation errors. I have included 'boost_regex-vc6-mt-1_33_1.lib' for URLHandler and no lib is specified for 'CacheStore'. Include path contains the paths Boost\include\boost-1_33_1 and Boost\lib Best Regards Mahesh Karanth Joaqu�n M� L�pez Mu�oz <joaquin@tid.es> wrote: Hello Mahesh, mahesh karanth ha escrito:
Unfortunately I am using 'using namespace std;' after all the include statements only.
And I am using VC 6
I think I should tell you how I have creted my workspace
I have a workspace in which a) 'Win32 console application' b)'Win32 Dinamic Link Library' (This project uses Boost.multi index) c)'Win32 Dinamic Link Library (This project uses Boost.Regex).
I have used both b) and c) dll's in main (Win32 console application).
Class hirarchy is as follows
WorkSpace -> main files , multiindex files , regex files
Which multi_index files? Boost.MultiIndex is a header only library. When you say "But when I indipendently compile multiindex package and regex package both compiles without any error." what do you mean by compiling multiindex package? Could you describe what is this process you do in more detail?
in the main I am calling the methods of multiindex and regex.
Maybe can you post the file of yours where the compile error shows? If you can't for confidentiality reasons, you can either post privately of at least send the includes part. I tend to think, along with John, you're implicitly issuing a using directive, maybe in some of your headers. Joaqu�n M L�pez Mu�oz Telef�nica, Investigaci�n y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost --------------------------------- New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

Hello again, mahesh karanth ha escrito:
1.URLHandler class which uses Boost.Regex
#ifndef _URLHANDLER_ #define _URLHANDLER_ ... using namespace boost; using namespace std; ... #endif
2.CacheStore class which uses Boost.multiindex
#ifndef _CACHESTORE_H_ #define _CACHESTORE_H_ ... using boost::multi_index_container; using namespace boost::multi_index; using namespace std; ... #endif //_CACHESTORE_H_
Both are of diffrent DLL's.
I am using the above two class inside the main() which looks as follows
#include "URLHandler.h" #include "CacheStore.h"
[...] Well, I guess the problem is one of the two "using namespace std" (or both) that you have in URLHandler.h and CacheStore.h. I'd try removing them (and explicitly std::-qualifying as necessary). Since you're at it, I'd also remove the other using's referring to multi_index, since in general it is bad idea to have them in header files. Good luck, and please report your results, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

I removed all 'using namespace std' , but problem still exists. Joaqu�n M� L�pez Mu�oz <joaquin@tid.es> wrote: Hello again, mahesh karanth ha escrito:
1.URLHandler class which uses Boost.Regex
#ifndef _URLHANDLER_ #define _URLHANDLER_ ... using namespace boost; using namespace std; ... #endif
2.CacheStore class which uses Boost.multiindex
#ifndef _CACHESTORE_H_ #define _CACHESTORE_H_ ... using boost::multi_index_container; using namespace boost::multi_index; using namespace std; ... #endif //_CACHESTORE_H_
Both are of diffrent DLL's.
I am using the above two class inside the main() which looks as follows
#include "URLHandler.h" #include "CacheStore.h"
[...] Well, I guess the problem is one of the two "using namespace std" (or both) that you have in URLHandler.h and CacheStore.h. I'd try removing them (and explicitly std::-qualifying as necessary). Since you're at it, I'd also remove the other using's referring to multi_index, since in general it is bad idea to have them in header files. Good luck, and please report your results, Joaqu�n M L�pez Mu�oz Telef�nica, Investigaci�n y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost --------------------------------- Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

mahesh karanth wrote:
When I compile 'URLHandler' and 'CacheStore' independently both will compile without any errors. But when integrated with main() gives the compilation errors.
Unfortunately there is no easy way around these errors as they're due to a compiler bug. As has already been suggested you need to ensure there are no "using namespace std;" statements floating around. Failing that it is possible to hack the regex headers: replacing collate with collate_ or something, but that's a rather error prone process. John.

I removed all using statements in my workspace and updated the corresponding references. Everthing went without any problems but at the end I got 2 errors Error dump: C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.h(1087) : error C2143: syntax error : missing ';' before 'constant' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.h(1087) : fatal error C1004: unexpected end of file found Error executing cl.exe. do you have any idea about this? I am using VC 6. Before when I was using using namespace's was not getting such error. Best Regards Mahesh Karanth John Maddock <john@johnmaddock.co.uk> wrote: mahesh karanth wrote:
When I compile 'URLHandler' and 'CacheStore' independently both will compile without any errors. But when integrated with main() gives the compilation errors.
Unfortunately there is no easy way around these errors as they're due to a compiler bug. As has already been suggested you need to ensure there are no "using namespace std;" statements floating around. Failing that it is possible to hack the regex headers: replacing collate with collate_ or something, but that's a rather error prone process. John. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost --------------------------------- New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

mahesh karanth ha escrito:
I removed all using statements in my workspace and updated the corresponding references. Everthing went without any problems but at the end I got 2 errors
Error dump:
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.h(1087) : error C2143: syntax error : missing ';' before 'constant' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.h(1087) : fatal error C1004: unexpected end of file found Error executing cl.exe.
do you have any idea about this? I am using VC 6.
The offending piece of wtypes.h looks like: typedef struct tagDEC { ... } DECIMAL; which directly clashes with your own definition of DECIMAL in URLHandler.h: #define DECIMAL 1 The solution is to use a different name for your macro. The usual recommendation to have macro names with low probability of collision is adding some weird and hopefully unique prefix, for instance some abbreviation of the name of the library or the company. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Thank you very much , Finally every thing compiled correctly now I am able to use Boost.Multiindex and Boost.Regex together. Thanks again Best Regards Mahesh Karanth Joaqu�n M� L�pez Mu�oz <joaquin@tid.es> wrote: mahesh karanth ha escrito:
I removed all using statements in my workspace and updated the corresponding references. Everthing went without any problems but at the end I got 2 errors
Error dump:
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.h(1087) : error C2143: syntax error : missing ';' before 'constant' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.h(1087) : fatal error C1004: unexpected end of file found Error executing cl.exe.
do you have any idea about this? I am using VC 6.
The offending piece of wtypes.h looks like: typedef struct tagDEC { ... } DECIMAL; which directly clashes with your own definition of DECIMAL in URLHandler.h: #define DECIMAL 1 The solution is to use a different name for your macro. The usual recommendation to have macro names with low probability of collision is adding some weird and hopefully unique prefix, for instance some abbreviation of the name of the library or the company. Joaqu�n M L�pez Mu�oz Telef�nica, Investigaci�n y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost --------------------------------- Get amazing travel prices for air and hotel in one click on Yahoo! FareChase

Hi John John Maddock ha escrito:
I'm at a loss as to why multi-index should trigger this problem, I hope it doesn't include global using statements like that.
No, it doesn't. I'm also at a loss with this, let's see if Mahesh can post a little more info. Joaquín M López Muñoz Telefónica, Investigaicón y Desarrollo
participants (3)
-
Joaquín Mª López Muñoz
-
John Maddock
-
mahesh karanth