Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 #define influences files it doesn't apply to
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Stephen
Tomato Guru

United Kingdom
781 Posts

Posted - May 25 2004 :  04:49:14 AM  Show Profile
We have a function Trace() in our app. We also use zlib, which #define's macros called Trace() internally, but doesn't expose them through its public interface.

In our app, the declaration of Trace() is coloured as if it were a macro:

  void Trace(LPCTSTR lpsz, WORD type = TRACE_GLOBAL);
  virtual BOOL InitInstance();

The definition is purple too. Hovering over the declaration shows the #define's from zutil.h. And the function appears to be unknown to VAX. It doesn't appear in the context bar. It's not known to ALT-G.

The file zutil.h, which #define's Trace(), is only used internally by zlib .c files. It's not exposed publically.

Stephen Turner
ClickTracks http://www.clicktracks.com/
Winner: ClickZ's Best Web Analytics Tool 2003 & 2004

Edited by - Stephen on May 25 2004 04:49:38 AM

Stephen
Tomato Guru

United Kingdom
781 Posts

Posted - Aug 13 2004 :  06:50:34 AM  Show Profile
It's got worse. I've now defined another function TraceEnabled(). Not only is Trace() still not recognised as a function, but whenever I type it, VAX automatically corrects it to TraceEnabled(), and I have to go back and delete the Enabled portion. This is very annoying.

<rant> I first reported this issue (or at least part of it) back in February. It seems to me that VAX has had some annoying parsing issues since the earliest builds, and I don't see much attempt to fix them. Templates are another big example. I'd really like to see the basic parsing improved before any new features are added. </rant>

Stephen Turner
ClickTracks http://www.clicktracks.com/
Winner: ClickZ's Best Web Analytics Tool 2003 & 2004
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Aug 18 2004 :  9:14:35 PM  Show Profile
Trace() is a macro #defined in Misc\\stdafx.h of the VA X installation directory. It exists to take precedence over an ugly version of Trace() found in ATL. Assuming you do not use ATL, you can remove Trace() from our stdafx.h.

Press Rebuild on our Performance node. Exit your IDE. Edit Misc\\stdafx.h. Restart your IDE. Assuming Trace() does not exist in another header somehow #included in your source, it should be colored as a method.

Since you say the hovering tooltip for Trace() shows a definition from zutil.h, we presume your project #includes zutil.h somehow. This will make VA X continue to color Trace() as a macro.

Do you have "Prefer default Intellisense" enabled in the Completion node of our options dialog? We recommend not enabling it, but if so, the definition you see in the tooltip might be one from MS. Actually, even with the option disabled, you might see a MS tooltip. The option sets only a preference.

You say also that typing Trace gets expanded to TraceEnabled. We define TraceEnabled and when we type Trace, we see a suggestion listbox with Trace and TraceEnabled. The latter is highlighted since we just typed it. If we press (, we keep our Trace and () is inserted.

If you enable "Accept suggestions with any character not valid in a symbol," pressing ( when TraceEnabled is highlighted in a suggestion listbox will insert the selection. Fnd this option in the Completion node of our options dialog. We strongly recommend you disable the option.

The option to "Accept suggestions with any character not valid in a symbol" exists primarily for VB users migrating to C/C++ or C#. They expect this behavior since it exists in VB.NET. We recommend Tab and/or Enter for everyone else.

If "Accept suggestions with any character not valid in a symbol" was NOT enabled, tell us what you typed, what listbox appeared, and what you typed after it appeared. Send or post a relevant screenshot just before the expansion from Trace to TraceEnabled.
Go to Top of Page

Stephen
Tomato Guru

United Kingdom
781 Posts

Posted - Aug 19 2004 :  05:18:15 AM  Show Profile
Thank you for your reply.

TRACE() was in stdafx.h, but not Trace(). I removed it anyway, but it didn't help.

zutil.h is #include'd in some cpp files, but not in the one I'm in (even indirectly). My suspicion is that VAX is just assuming that all #define's apply everywhere, whether or not the file is #include'd at the time.

Prefer default intellisense: off
Accept suggestions with: tab and return only

I have now discovered that plain Trace doesn't get corrected (after all, VAX thinks there's a macro of that name). But "this->Trace(" gets corrected to "this->TraceEnabled(" because VAX doesn't know about any this->Trace().

Screenshots immediately before and after pressing "(" on their way. You can post them here if you wish.

Stephen Turner
ClickTracks http://www.clicktracks.com/
Winner: ClickZ's Best Web Analytics Tool 2003 & 2004
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Aug 19 2004 :  5:16:53 PM  Show Profile


Go to Top of Page

Uniwares
Tomato Guru

Portugal
2322 Posts

Posted - Aug 19 2004 :  5:20:07 PM  Show Profile
When programming is not more a challenge by itself, you can start using Stephens color scheme
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Aug 19 2004 :  5:27:48 PM  Show Profile
Pictures speak a thousand words.

In your first screenshot, our definition field describes the highlighted selection. It does not describe Trace() within your class.

Type Trace without "this". Press ESC if a listbox is open. Type (). Click on Trace.

Trace is probably colored like a macro and its definition appears in our Definition field. Its definition exists somewhere, whether your #include it or not. Presumably zutil.h.

Your assumption is correct that macros are global during editing. We realize this is not the case during compile. Unfortunately, we cannot accurately determine which macros are #defined and which are not for a given file, since that answer depends on what is #defined during compile, and the order of the compile. Our sloppy solution is to make all macros global during edit, at least when parsing definitions.

Unfortunately, VA X uses the global macro for Trace() when parsing the definition of your class. The macro confuses VA X so it does not realize such a method exists in your class. (The macro for Trace() in zutil.h probably doesn't expect to be part of a class definition.)

Although #defined in zutil.h, VA X knows Trace() is valid in your current context. (Remember, the expanded version of the Trace() macro confused VA X while parsing your class definition.) This is the reason your suggestion listbox contains only TraceEnabled().

If you press ( when a suggestion is highlighted and what you have typed so far is not valid, VA X inserts the selection. In this case, VA X inserts TraceEnabled().

A highlighted suggestion is inserted with ( whether or not "Accept suggestions with any character no valid in a symbol" is checked. This behavior exists with the default behavior of the IDE.

Here is the workaround to make VA X forget about the global definition of Trace, and subsequently parse your class correctly:

Press Rebuild on our Performance node. Exit your IDE and edit your Misc\\stdafx.h again. Add this entry:

#define Trace Trace

Restart your IDE.

Edited by - support on Aug 19 2004 5:35:38 PM
Go to Top of Page

Stephen
Tomato Guru

United Kingdom
781 Posts

Posted - Aug 20 2004 :  04:31:50 AM  Show Profile
Thanks very much for your support, support. Your workaround was partially successful:
  1. Trace is still coloured as a macro, but that's not a big problem.
  2. Trace is no longer "corrected" to TraceEnabled.
  3. Trace is now present in the SIW, but...
  4. VAX still only knows about the declaration, not the definition. Choosing CRorschachApp.Trace in the SIW jumps to the declaration. Alt-G only jumps to the declaration. CRorschachApp.Trace doesn't appear in the VAX context bar.
Still, the worst problem is solved. If this is the best workaround, I can live with the rest.

A couple more comments:

1) I knew VAX didn't resolve the #ifdef's of course, but I didn't realise it didn't follow the #include's either. Is this really not possible? Or not desirable?

I realise you want to make sure that all valid symbols are known about. False negatives are bad, but my instinct is that you have problems with false positives at the moment, especially where one common word is declared in two different ways.

I don't pretend to understand the trade-offs here though.

2) I'm surprised that '(' accepts a selection when I've asked for only Tab and Return to accept suggestions. I don't understand your explanation, but the behaviour seems wrong to me. Sometimes I use function names and only later go back and declare/define them, and I don't want other suggested symbols inserted instead when I haven't asked for them.

Stephen Turner
ClickTracks http://www.clicktracks.com/
Winner: ClickZ's Best Web Analytics Tool 2003 & 2004
Go to Top of Page

Stephen
Tomato Guru

United Kingdom
781 Posts

Posted - Aug 20 2004 :  04:34:57 AM  Show Profile
And as for the colour scheme, Andreas, I'm very pleased with it. I find a white background all day very tiring on the eyes. But I still prefer black text, so I don't want to have white text on a black background. A mid-grey background works very well.

Stephen Turner
ClickTracks http://www.clicktracks.com/
Winner: ClickZ's Best Web Analytics Tool 2003 & 2004
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Aug 20 2004 :  05:59:00 AM  Show Profile
quote:
Originally posted by support

A highlighted suggestion is inserted with ( whether or not "Accept suggestions with any character no valid in a symbol" is checked. This behavior exists with the default behavior of the IDE.


Stephen, it seems ( is accepting the suggestion since this is what the IDE with no VAX does. obviously someone at Microsoft thinks this is a good idea, and VAX is following their lead on this one *shrug*

now and then i do the same as you, calling functions i haven't yet defined. i don't do this often, but it does happen.

as for the colour scheme, i agree that black text and an off white background is good. however, on this monitor i can hardly see the text, let alone read it! i suspect Uniwares is having a similar experience

zen is the art of being at one with the two'ness
Go to Top of Page

Stephen
Tomato Guru

United Kingdom
781 Posts

Posted - Aug 20 2004 :  07:39:19 AM  Show Profile
Maybe it's different on a CRT. I'm using an LCD screen.

Stephen Turner
ClickTracks http://www.clicktracks.com/
Winner: ClickZ's Best Web Analytics Tool 2003 & 2004
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Aug 20 2004 :  5:46:02 PM  Show Profile
1) VA X does follow #includes -- that's how it knows what's valid in any given context, at least in terms of suggestions, completion lists and the Definition field. Coloring is done a bit differently.

Adding a #define for Trace in Misc\\stdafx.h gave VA X a "super global" definition that takes precendence over all others. Not finding your version of its definition is a side effect.

2) Accepting suggestions with ( is a tough call. MS lets it happen with completion listboxes. We follow their lead with all listboxes so people accustomed to the behavior prior to VA X don't fumble after installing VA X.

Perhaps we should distinguish suggestions from completion lists, letting ( accept only from the latter. The problem with this is people don't often both to distinguish the two. The ( would work some times, not others. Annoying.

We could add an option, but we don't like excessive options. In this case, we'd force you to understand the issue so you could select a preference. We prefer just to make the software work.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000