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
 1624 C++ parser issue
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

udoeb
Junior Member

12 Posts

Posted - Jan 18 2008 :  02:22:28 AM  Show Profile  Reply with Quote
Hello,

I found that VAX is not able to parse the following C++ member function definition because of the #pragma statement:

class Xxx
{
public:
// acquire mutex
void
AcquireFastMutex()
// suppress PREfast report
#pragma warning(suppress:28167)
{
_ASSERT(IRQL_LTEQ_APC());
ExAcquireFastMutex(this);
}

VAX does not recognize AcquireFastMutex as a valid member function and underlines this symbol whenever it is used.

Background info: PREfast is a special Microsoft tool used for device driver development. Unfortunately, PREfast requires to place #pragma statements exactly as shown in the code above. Moving the #pragma statement before the function definition will not work.

Any comments are welcome.

Udo

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Jan 18 2008 :  1:14:17 PM  Show Profile  Reply with Quote
Which bits of this are required? There are a couple of typo's in your code sample, no semi-colon after AcquireFastMutex and no closing curly bracket.

The underlining is being caused by the curly brackets inside the class, VA is not expecting these. Simplifying this down, VA is confused by:

class Xxx
{
	{
		void ExAcquireFastMutex();
	}
}

which is understandable, since this does not actually compile.

Interestingly enough this does not compile either:

class Xxx
{
	#pragma warning(suppress:28167)
	{
		void ExAcquireFastMutex();
	}
}


I am using VS2005 and compiling this as C++. Are you actually compiling this as C++? Or as some other language?

I do not recognise PREfast and do not know anything about it.

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

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Jan 18 2008 :  2:13:37 PM  Show Profile  Reply with Quote
I see what is going on now. VA is confused by the #pragma statement between the function signature and body.

VA understands this simplified example:

#ifdef VA_HELPER_CODE_HERE
#define PRAGMA_LINE
#else
#define PRAGMA_LINE #pragma warning(suppress:28167)
#endif

class testThingsGenerally
{
	void FunctionWithDirective()
PRAGMA_LINE
	{
	} 
};

unfortunately it does not compile in VS2005, which is a rather serious flaw.

I have put in a bug report for this:

case=11545

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

mwb1100
Ketchup Master

82 Posts

Posted - Jan 18 2008 :  3:01:08 PM  Show Profile  Reply with Quote
You may be able to apply feline's workaround using the __pragma keyword (which I think MS introduced in VS2005, but maybe in some other version). It's similar to (but not quite the same as) the _Pragma keyword in C99, which is intended to allow macros to deal with pragmas:

From http://msdn2.microsoft.com/en-us/library/d9x1s805.aspx:

The compiler also supports the __pragma keyword, which has the same functionality as the #pragma directive, but can be used inline in a macro definition. The #pragma directive cannot be used in a macro definition because the compiler interprets the number sign character ('#') in the directive to be the stringizing operator (#).
Go to Top of Page

udoeb
Junior Member

12 Posts

Posted - Jan 25 2008 :  09:39:33 AM  Show Profile  Reply with Quote
Thanks feline for filing a bug report. I really think that is a parser issue. VAX should simply ignore a #pragma statement despite its location.

Thanks mwb1100 for pointing me to the __pragma keyword. This could be an acceptable workaround. However, in this specific case the #pragma needs to be understood by the PREfast tool, not by the compiler. I will check if PREfast supports __pragma too.

Regards,
Udo
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000