Using Boost without confusing Intellisense

Hi, I use many Boost libraries, develop with MSVC (currently 2008), and build both my project and its Boost dependencies with Boost.Build. The one thing that's always frustrated me using boost is its tendency to confuse MSVC's Intellisense. I don't know if this holds true for other IDEs with an Intellisense-like capability, but heavy use of boost::shared_ptr and BOOST_FOREACH in particular seem to confuse Intellisense in a large project. MSVC never knows what to show when dereferencing a shared_ptr and it never defines the instance variable in BOOST_FOREACH. I came up with two fairly simple workarounds for this but I'm interested to hear if there's a better solution. If not, I'm wondering if the workarounds could go in boost itself. For shared_ptr, I use a conditional macro like: #ifdef INTELLISENSE #define TYPEDEF_SHARED_PTR(type) typedef type* type##Ptr #else #define TYPEDEF_SHARED_PTR(type) typedef boost::shared_ptr<type> type##Ptr #endif For BOOST_FOREACH, I do basically the same thing: #ifdef INTELLISENSE #define BOOST_FOREACH(a, b) a; #else #include <boost/foreach.hpp> #endif Then I just add INTELLISENSE to the VC project's preprocessor macros (not my build system) and Intellisense gets the job done a lot more often. I didn't look into whether MSVC defines an automatic preprocessor variable when Intellisense is parsing (which would be useful for helping it navigate complex code), but of course that would be even better. The obvious flaw for TYPEDEF_SHARED_PTR in my implementation is that it assumes a particular variable name scheme, but an "official" version could make both type names explicit. The are some other confusing libs like Boost.Preprocessor but I don't think they are as commonly used. The nice thing about these workarounds is they can be applied separately to each library. I'm wondering if other boost devs or users would be interested in having these workarounds in the official boost distro. For the smart_ptrs, it could go at the end of the headers. For BOOST_FOREACH, the whole foreach.hpp could be surrounded by #ifndef INTELLISENSE (so that all the stuff inside it doesn't need to be parsed for Intellisense) and the #else would define BOOST_FOREACH and BOOST_REVERSE_FOREACH as I did above. If not, maybe it's time I switched IDEs. Are there any that provide Intellisense-like capability with smart_ptrs and BOOST_FOREACH? :) Thanks, -Matt

Hi, 9-2-2011 17:29, Matthew Chambers wrote:
Hi,
I use many Boost libraries, develop with MSVC (currently 2008), and build both my project and its Boost dependencies with Boost.Build. The one thing that's always frustrated me using boost is its tendency to confuse MSVC's Intellisense. I don't know if this holds true for other IDEs with an Intellisense-like capability, but heavy use of boost::shared_ptr and BOOST_FOREACH in particular seem to confuse Intellisense in a large project. MSVC never knows what to show when dereferencing a shared_ptr and it never defines the instance variable in BOOST_FOREACH.
I came up with two fairly simple workarounds for this but I'm interested to hear if there's a better solution. If not, I'm wondering if the workarounds could go in boost itself. (...)
I had the same experience with MSVC 2005 and 2008, developing Boost.Geometry. We don't use shared_ptr there, and BOOST_FOREACH neither, but still I had this issue (it hangs forever). Anyway, it is relatively easy to solve by turning off Intellisense completely... It is described on this page: http://geometrylibrary.geodan.nl/compiling.html referring to: http://bit.ly/ePGedN Regards, Barend

On 2/9/2011 11:53 AM, Barend Gehrels wrote:
Anyway, it is relatively easy to solve by turning off Intellisense completely...
It is described on this page:
http://geometrylibrary.geodan.nl/compiling.html
referring to:
Regards, Barend
Thanks for the tip, but my goal is to keep Intellisense and benefit from it! The cumulative effect of developing with Intellisense or something like it is huge. It certainly lets me code in C# a hell of a lot faster than in C++ (even using the same library!). -Matt

[Matthew Chambers]
my goal is to keep Intellisense and benefit from it!
Intellisense was completely reimplemented between 2008 and 2010. They threw away FEACP, a flaky mutant build of our real C++ front-end C1XX, and replaced it with EDG's front-end, which is renowned for its conformance. As a result, Boost shouldn't confuse Intellisense anymore. I suggest upgrading to 2010 immediately. If you encounter any remaining problems, please report them immediately - our Intellisense team is very diligent about fixing differences between C1XX and EDG. (I speak from experience, since the STL's implementation involves compiler-stressing code, although not as much as Boost!) Stephan T. Lavavej Visual C++ Libraries Developer

Stephan T. Lavavej wrote on: Wednesday, February 09, 2011 3:05 PM
Intellisense was completely reimplemented between 2008 and 2010. They threw away FEACP, a flaky mutant build of our real C++ front-end C1XX, and replaced it with EDG's front-end, which is renowned for its conformance. As a result, Boost shouldn't confuse Intellisense anymore.
I suggest upgrading to 2010 immediately. If you encounter any remaining problems, please report them immediately - our Intellisense team is very diligent about fixing differences between C1XX and EDG. (I speak from experience, since the STL's implementation involves compiler- stressing code, although not as much as Boost!)
My group upgraded to MSVC2010 recently on my recommendation. 2010 has its own issues that may be just as annoying as the 2008 Intellisense, if not more so, including (in my experience) - a deathly slow editor - no Multiple Document Interface - a separate Intellisense server created process for each open document (my understanding- correct me if I'm wrong) - frequent crashes of these background processes - CPU hog - much slower compiles Some of these are subjective (and the Intellisense accuracy is improved from 2008), but it's a bit of a mixed bag overall. Erik ---------------------------------------------------------------------- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to "Sender" are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing.

On 2/9/2011 2:36 PM, Nelson, Erik - 2 wrote:
My group upgraded to MSVC2010 recently on my recommendation. 2010 has its own issues that may be just as annoying as the 2008 Intellisense, if not more so, including (in my experience)
- a deathly slow editor - no Multiple Document Interface - a separate Intellisense server created process for each open document (my understanding- correct me if I'm wrong) - frequent crashes of these background processes - CPU hog - much slower compiles
I have both 2010 and 2008 installed and I have experienced these issues as well as the showstopper for me: no Intellisense for C++/CLI. I also tend to have at least 3 solutions open at once, and 2010's just too much of a hog to do that. Regardless, there are going to be lots of sites still using MSVC 2005 and 2008 for a long time to come (consider MSVC6's sadly entrenched userbase), and I think simple workarounds like I've proposed would significantly ease development with boost when used with these IDEs. It would probably even make the 2010 Intellisense more stable. -Matt

On 09/02/11 17:53, Barend Gehrels wrote:
9-2-2011 17:29, Matthew Chambers wrote:
Hi,
I use many Boost libraries, develop with MSVC (currently 2008), and build both my project and its Boost dependencies with Boost.Build. The one thing that's always frustrated me using boost is its tendency to confuse MSVC's Intellisense. I don't know if this holds true for other IDEs with an Intellisense-like capability, but heavy use of boost::shared_ptr and BOOST_FOREACH in particular seem to confuse Intellisense in a large project. MSVC never knows what to show when dereferencing a shared_ptr and it never defines the instance variable in BOOST_FOREACH.
I came up with two fairly simple workarounds for this but I'm interested to hear if there's a better solution. If not, I'm wondering if the workarounds could go in boost itself. (...)
I had the same experience with MSVC 2005 and 2008, developing Boost.Geometry. We don't use shared_ptr there, and BOOST_FOREACH neither, but still I had this issue (it hangs forever).
Anyway, it is relatively easy to solve by turning off Intellisense completely...
I agree with Barend, For me, it's impossible to use IS with Boost in Visual Studio 2005 which crashes every time I trigger completion. However, Visual Studio 2010 works well for me. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org Member of ACCU, http://accu.org

Matthew Chambers <matt.chambers42 <at> gmail.com> writes:
Hi,
I use many Boost libraries, develop with MSVC (currently 2008), and build both
my project and its
Boost dependencies with Boost.Build. The one thing that's always frustrated me using boost is its tendency to confuse MSVC's Intellisense. I don't know if this holds true for other IDEs with an Intellisense-like capability, but heavy use of boost::shared_ptr and BOOST_FOREACH in particular seem to confuse Intellisense in a large project. MSVC never knows what to show when dereferencing a shared_ptr and it never defines the instance variable in BOOST_FOREACH.
Intellisense is useless in many situations. The best thing to do IMO is to disable it completely and install Visual Assist, which has a far more competent code parser than Intellisense. VS2010 has a completely reworked Intellisense implementation, but unfortunately it is still much slower than Visual Assist (thus adding to the general slowness and bloat of VS2010...). Jarl

Jarl Lindrud wrote:
Matthew Chambers <matt.chambers42 <at> gmail.com> writes:
Hi,
I use many Boost libraries, develop with MSVC (currently 2008), and build both my project and its Boost dependencies with Boost.Build. The one thing that's always frustrated me using boost is its tendency to confuse MSVC's Intellisense. I don't know if this holds true for other IDEs with an Intellisense-like capability, but heavy use of boost::shared_ptr and BOOST_FOREACH in particular seem to confuse Intellisense in a large project. MSVC never knows what to show when dereferencing a shared_ptr and it never defines the instance variable in BOOST_FOREACH.
Intellisense is useless in many situations. The best thing to do IMO is to disable it completely and install Visual Assist, which has a far more competent code parser than Intellisense.
I generally agree although for me, Visual Assist has problems inside boost.test methods, and just doesn't seem to ever want to offer boost::bind, it always ends up with bind1st or some other variant.
VS2010 has a completely reworked Intellisense implementation, but unfortunately it is still much slower than Visual Assist (thus adding to the general slowness and bloat of VS2010...).
Good to know. Jeff

On Wed, 09 Feb 2011 08:29:11 -0800, Matthew Chambers <matt.chambers42@gmail.com> wrote:
Hi, I use many Boost libraries, develop with MSVC (currently 2008), and build both my project and its Boost dependencies with Boost.Build. The one thing that's always frustrated me using boost is its tendency to confuse MSVC's Intellisense. I don't know if this holds true for other IDEs with an Intellisense-like capability, but heavy use of boost::shared_ptr and BOOST_FOREACH in particular seem to confuse Intellisense in a large project. MSVC never knows what to show when dereferencing a shared_ptr and it never defines the instance variable in BOOST_FOREACH.
Eclipse CDT is actually pretty good with code completion, code navigation, and code editing. I've had no problems with shared_ptr. Though, it's context menu is a little cluttered, doesn't work with libtool+gdb combo, you're going to have to put some effort into getting the project setup if your project structure isn't tied to the filesystem, and from time to time they can have some really annoying regressions in their releases, so try out new releases before adopting them. Mostafa

On Wed, 09 Feb 2011 16:14:22 -0800, Mostafa <mostafa_working_away@yahoo.com> wrote:
On Wed, 09 Feb 2011 08:29:11 -0800, Matthew Chambers <matt.chambers42@gmail.com> wrote:
Hi, I use many Boost libraries, develop with MSVC (currently 2008), and build both my project and its Boost dependencies with Boost.Build. The one thing that's always frustrated me using boost is its tendency to confuse MSVC's Intellisense. I don't know if this holds true for other IDEs with an Intellisense-like capability, but heavy use of boost::shared_ptr and BOOST_FOREACH in particular seem to confuse Intellisense in a large project. MSVC never knows what to show when dereferencing a shared_ptr and it never defines the instance variable in BOOST_FOREACH.
Eclipse CDT is actually pretty good with code completion, code navigation, and code editing. I've had no problems with shared_ptr. Though, it's context menu is a little cluttered, doesn't work with libtool+gdb combo, you're going to have to put some effort into getting the project setup if your project structure isn't tied to the filesystem, and from time to time they can have some really annoying regressions in their releases, so try out new releases before adopting them.
Forgot to add, it's highly customizable too, the usual key-bindings is there, but you can also define your own automated code-style formatting. Mostafa

2011/2/10 Mostafa <mostafa_working_away@yahoo.com>
On Wed, 09 Feb 2011 08:29:11 -0800, Matthew Chambers < matt.chambers42@gmail.com> wrote:
Hi,
I use many Boost libraries, develop with MSVC (currently 2008), and build both my project and its Boost dependencies with Boost.Build. The one thing that's always frustrated me using boost is its tendency to confuse MSVC's Intellisense. I don't know if this holds true for other IDEs with an Intellisense-like capability, but heavy use of boost::shared_ptr and BOOST_FOREACH in particular seem to confuse Intellisense in a large project. MSVC never knows what to show when dereferencing a shared_ptr and it never defines the instance variable in BOOST_FOREACH.
Eclipse CDT is actually pretty good with code completion, code navigation, and code editing. I've had no problems with shared_ptr. Though, it's context menu is a little cluttered, doesn't work with libtool+gdb combo, you're going to have to put some effort into getting the project setup if your project structure isn't tied to the filesystem, and from time to time they can have some really annoying regressions in their releases, so try out new releases before adopting them.
Mostafa
Same here: Eclipse CDT code completion works about 90% of the time, with code using boost, including shared_ptr. I don't use BOOST_FOREACH, but I would expect it to work as well. Regards, Kris.
participants (9)
-
Barend Gehrels
-
Jarl Lindrud
-
Jeff Flinn
-
Krzysztof Czainski
-
Mateusz Loskot
-
Matthew Chambers
-
Mostafa
-
Nelson, Erik - 2
-
Stephan T. Lavavej