Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 1624 C++ parser issue

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
udoeb Posted - Jan 18 2008 : 02:22:28 AM
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
4   L A T E S T    R E P L I E S    (Newest First)
udoeb Posted - Jan 25 2008 : 09:39:33 AM
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
mwb1100 Posted - Jan 18 2008 : 3:01:08 PM
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 (#).
feline Posted - Jan 18 2008 : 2:13:37 PM
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
feline Posted - Jan 18 2008 : 1:14:17 PM
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.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000