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
 #defines in stdafx.h fail with nested parentheses
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

RichieHindle
New Member

United Kingdom
7 Posts

Posted - Jul 07 2004 :  09:18:33 AM  Show Profile
We use some macros for function declarations and definitions that let us code for both K&R and ANSI C compilers. My Misc\\stdafx.h contains the following definitions, which make the code below compile to ANSI C:

#define _A_(args) (
#define _C_ ,
#define _E_ )

(we have alternative definitions of those macros that turn it into K&R C).

Despite this, first_parameter and second_parameter are both drawn with a red underline in all the places they appear.

If I change '((' to '(' and '))' to ')' then VAX highlights the code correctly (but obviously the code won't compile). It looks as though the VAX parser doesn't understand that parentheses can be used to wrap macro arguments.

We have a lot of code that's written in this style, and using VAX with it is quite frustrating.


int add _A_(( first_parameter, second_parameter ))

int first_parameter _C_
int second_parameter _E_

{
   return first_parameter + second_parameter;
}

support
Whole Tomato Software

5566 Posts

Posted - Jul 07 2004 :  3:42:35 PM  Show Profile
Brutal.

VA X doesn't parse to the basic types as a real compiler does. VA X tries to keep definitions fairly close to the source level -- something much more meaningful when editing.

Here is the best workaround we have for you:

Press Rebuild on the Performance node of our options dialog.
Exit your IDE.
Add this to stdafx.h in the Misc\\ subdirectory of the VA X installation directory:

#define _A_() ;
#define _C_() ;
#define _E_() ;

Restart your IDE.

Though VA X will not provide Auto Parameter Info for add(), it should know the types for the individual parameters.

Note the use of () in our defines -- this tells VA X to resolve the macro one level before evaluating a definition in which it is used.

Whole Tomato Software, Inc.
Go to Top of Page

RichieHindle
New Member

United Kingdom
7 Posts

Posted - Jul 08 2004 :  05:36:29 AM  Show Profile
Many thanks for the workaround! I do get Auto Parameter Info, because there's a piece of our macro system I didn't explain. This:

  #define _P_(args) args

lets us define prototypes like this:

  int add _P_(( int first_parameter, int second_parameter ));

and VA X find those OK (I'm not sure why, but it does ).

I now no longer get red underlines everywhere, and I can jump to the definition of a function parameter (sort of - it jumps to the _A_ rather than the variable, but it's near enough).

There's one thing not working, and I'm sure with the right #define it could be made to work. VA X isn't seeing functions defined with _A_ as function definitions. This means I don't get the functions listed in the Context dropdown or the Hovering Browser, and when I do Ctrl+G I'm taken directly to the declaration rather than being given a menu that includes the definition. Can I define _A_ in such a way as to make VA X think it's seeing a function definition? I tried:

  #define _A_() ();

but it didn't change anything.
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Jul 08 2004 :  3:15:28 PM  Show Profile
We tried several ideas. No luck.

We will let you know if we think of something to help.

Whole Tomato Software, Inc.
Go to Top of Page

RichieHindle
New Member

United Kingdom
7 Posts

Posted - Jul 09 2004 :  03:58:48 AM  Show Profile
Thanks. Given the weirdness of the code I'm happy it works as well as it does, but if you do come up with anything to improve things further I'd love to know.

PS. Is it possible to subscribe to a forum topic, to be emailed when a new post appears? The forum FAQ says you can, but none of the commands appears in the forum.
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Jul 09 2004 :  12:40:12 PM  Show Profile
We enabled subscriptions in our Forums. You are welcome to subscribe to this topic.

As for regular viewing of our Forums, we recommend viewing "Active Topics."

Whole Tomato Software, Inc.
Go to Top of Page

RichieHindle
New Member

United Kingdom
7 Posts

Posted - Jul 12 2004 :  03:50:19 AM  Show Profile
quote:
We enabled subscriptions in our Forums. You are welcome to subscribe to this topic.


Wonderful - many thanks.
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