Blog O Sparky archive

Displaying macros in Code Completion (C++Builder2006)

If you’ve ever used C or C++ you know about macros and their [ab]uses. Macros can be used in a number of ways, one of which is to substitute a string of text for a single identifier as in:

#define MAX_TYPEVECSIZE (sizeof(typeVec[0]) * vecLength)

you may also declare them as a parameterized macro (looks like a function call) as in:

#define isVisible(t) (((t)->flags & VIS_MASK) >= VIS_PUBLIC)

Note that both of these macros are indistinguishable from regular symbols (lexical identifiers) in source code. Doesn’t code completion show you what identifiers are available in a specific context? Why yes, it does. So why doesn’t it also show the macros that are available? In fact, the ability for Code Completion to show macros has been there since BCB6 (this same trick, in the root Code Insight key, should work in that IDE as well), but it has been turned off by default for two reasons:

  1. There was concern that it would be seen as extra noise in the Code Completion list (I disagree with this one).
  2. It increases the size of the Code Completion list (and depending on which headers you’re including there could be thousands of extra macros) thus it increases the amount of time taken to show the list since the sort routine has quite a few more items to sort.

To turn it on change the value of the following registry string value to True:

xxxBDS4.0Code InsightBorland.EditOptions.CShow Macros = True

/* If there is a blank spot here, scroll down to see the rest of the blog */

Restarting the IDE should not be necessary.

You should now be able to see macros in the Code Completion list.

As an additional note, you can also turn on/off the namespace prefixes that are shown in the Code Completion list by changing the Show Namespaces registry string value (this is in the same key as the Show Macros string value) to True/False, respectively. Let me know if you find this useful!

Posted by Adam Markowitz archive on December 19th, 2005 under Uncategorized |



4 Responses to “Displaying macros in Code Completion (C++Builder2006)”

  1. John McLaine Says:

    You are competing seriously to be one of my most visited blogs :-)… I feel like a dog being given a cookie every day… thanks for giving those infos… I can’t tell you if it is usefull or not since I only code in Delphi Language/Pascal… but I will wait for some "new" hidden goodie :-)
    John.

  2. Chee Wee Chua Says:

    Another useful tip!

    Thanks, Sparky!

  3. Chris Bruner Says:

    Yup. It’s useful. Thanks! (CBuilder 6 user)

  4. Liz Kimber Says:

    Wow, you have all the hidden extras :) Cant wait to see what else you have waiting for us all, its like tuning into a fave series :)



Server Response from: blog1.codegear.com