Click here to Skip to main content
Licence 
First Posted 24 Dec 2003
Views 42,641
Bookmarked 15 times

Using WTL with Intellisense

By | 24 Dec 2003 | Article
Normally, Intellisense doesn't work correctly with WTL. Here is a workaround.

Introduction

After deciding that MFC was too bloated for my liking, I discovered WTL. I read the various articles on CodeProject about them, and was eager to try this excellent new wrapper for Win32. (Imagine... no support files necessary!)

Unfortunately, I soon discovered that my favorite part of Visual Studio, Intellisense, didn't work correctly. I was frustrated by this, because I am a heavy Intellisense user. Throughout the course of my frustration, I decided to buy Visual C++ .NET 2003. (I had VC2002 initially.) When that didn't solve my problems, although it relieved a few unrelated ones, I decided to try to find another way.

In actuality, I had a solution ready in 5 minutes. I got an idea from someone who said they included all of the WTL header files in their project. I thought that was messy, and decided to try including them in a static library. The library itself doesn't do anything special.

There may be other solutions, and if you have one, feel free to post so I can update the article accordingly. But I decided to write my first article for this, since it has helped me and hopefully will help others.

Included Source Files

In the source files linked at the top of this article, you will find a Static Library. If you don't wish to follow the steps below, you can download the source ZIP and skip to step 4. NOTE: It was created in VS2003, and uses the WTL 7.1 headers.

A Workaround

  • Step 1: Create a new Win32 Project. I used "WTL71Intellisense" for the project name, because that is the version of WTL I am using. Select "Static Library" under "Application Settings". The rest remain at their default. (Precompiled Headers, no MFC)
  • Step 2: Right-click on the Project name in Project Explorer. Choose "Add" > "Add Existing Item". Navigate to the '(WTL)\include' directory that you keep your WTL headers in. Select all of the items, and add them to the project.
  • Step 3: Make sure you are in Release mode, and build the library. If all goes well, your library should build. Go to the "Release" directory, and find the .lib file.
  • Step 4: Place the .lib file in your Library directory. Mine is C:\Program Files\Visual Studio Projects\vc7\lib directory. (with VS2003. With other installs yours may be different)

You're done! To use the library:

  • Step 1: Right-click on the Project name in Project Explorer. Choose "Properties", and go to the "Linker" tab, subsection "Input". Select "All Configurations".
  • Step 2: In the "Additional Dependencies", add the name of the library file. (e.g. WTL71Intellisense.lib)

Intellisense should now work correctly.

Notes

  • Especially with MFC projects, as with any WTL project, be careful about name collisions in your code.
  • You don't need to change anything else in your project besides linking in the library.
  • Linking the library should not affect your executable.
  • If you change the WTL source files, it would be wise to rebuild the library project.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Shutter



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralWorkaround to let IntelliSense work with any user-defined headerfile PinmemberTroubelman21:41 19 Jan '05  
GeneralExellent! PinmemberErnesto D.22:30 27 Nov '04  
GeneralSimpler solution for VC 6.0 Pinmemberweelink3:17 15 Jan '04  
GeneralSome advertising... PinmemberRalph Wetzel0:59 25 Dec '03  
GeneralRe: Some advertising... PinmemberWREY15:34 1 Jan '04  
GeneralRe: Some advertising... PinmemberRalph Wetzel0:50 2 Jan '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 25 Dec 2003
Article Copyright 2003 by Shutter
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid