This isn't anything to worry about is it?Code:Assert( uAddress < VMM_MEM, "AddProperty: Invalid address" );
This isn't anything to worry about is it?Code:Assert( uAddress < VMM_MEM, "AddProperty: Invalid address" );
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
It might be. What's the context, and the exact compiler warning?
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Context might be helpful -- like the declaration of Assert, the type of uAddress, the value of VMM_MEM.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
As in:
Assert is defined as:Code:void VMMemory::Write( unsigned uAddress, DWORD dwVal ) { Assert( uAddress < VMM_MEM, "Invalid address for VM memory write" ); *( m_dwMemory + uAddress ) = dwVal; }
AssertDialog is your bog standard Win32 Dialog launcher (DialogBox()) and also takes care of some other stuff.Code:// I pass false or true to AssertDialog here instead of bExpr to avoid a 4800 warning // This should improve performance too, judging by the actual warning message #define Assert( bExpr, szErrText ) ( !bExpr ) ? AssertDialog( false, ##szErrText ) : AssertDialog( true, "" );
Code:void AssertDialog( bool bEval, const char* szExprText );
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
Lacking parentheses, can you take a guess at the expansion? Hint:Originally Posted by ahluka
And I doubt you want to have the habit of terminating a macro with a semicolon.Code:!uAddress < VMM_MEM
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Yay fixed it - the warning at least.
You meant this right?
Code:#define Assert( bExpr, szErrText ) ( !(bExpr) ) ? AssertDialog( false, ##szErrText ) : AssertDialog( true, "" );
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
I'd remove the trailing semicolon, and why are you using ##?
[edit]What would be wrong with this?
Code:void Write( unsigned uAddress, DWORD dwVal ) { AssertDialog( uAddress >= VMM_MEM, "Invalid address for VM memory write" ); // ... }
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Absolutely nothing at all. T'is a good idea - thankies
Plus it removes the ambiguation between the standard library Assert macro - my IDE displays two when I type the opening parenthesis. Not a problem, just annoying.
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry