Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Halt Macro

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stanley Durham
    replied

    Contract Programming
    Contracts are a breakthrough technique to reduce the programming effort for large projects. Contracts are the concept of preconditions, postconditions, errors, and invariants.
    The idea of a contract is simple - it's just an expression that must evaluate to true. If it does not, the contract is broken, and by definition, the program has a bug in it. ...
    Assert Contract
    The most basic contract is the assert. An assert inserts a checkable expression into the code, and that expression must evaluate to true:
    assert(expression);

    Leave a comment:


  • Stanley Durham
    replied
    Very nice try, sir.
    No Sale.
    wasn't trying to sale, just explain


    assert.h is a header file in the standard library of the C programming language that defines the C preprocessor macro assert(). The macro implements an assertion, which can be used to verify assumptions made by the program.
    The assert() macro inserts diagnostics into programs. When executed, if the expression is false (that is, compares equal to 0), assert() writes information about the call that failed on stderr and then calls abort(). The information it writes to stderr includes:
    the text of expression that evaluated to 0
    the source filename (the predefined macro __FILE__)
    the source line number (the predefined macro __LINE__)
    The C99 adds:
    the source function (the predefined macro __func__)
    Programmers can eliminate the assertions without changing the source code: if the macro NDEBUG is defined before the inclusion of <assert.h>, the assert() macro is defined simply as:
    #define assert(ignore)((void) 0)
    and therefore has no effect on the program, not even evaluating its argument.

    Leave a comment:


  • Michael Mattias
    replied
    > The idea is ...

    Very nice try, sir.

    No Sale.

    Leave a comment:


  • Stanley Durham
    replied
    The idea is to use it to test a module of code: include file.
    After code is tested;
    - take it out
    - leave it in as a double-backup to your error handling methods
    Error handling code is also error-prone.
    If your error handling is good, it would be impossible to happen.

    Leave a comment:


  • Stanley Durham
    replied
    Paul,
    on Windows 7
    "Problem signature:"
    " Problem Event Name: APPCRASH"

    On my PC I get OllyDebug popping up.
    that's OK if it's used to get test code up to speed without having to write
    an error handling system into the code.

    Leave a comment:


  • George Bleck
    replied
    Originally posted by Chris Holbrook View Post
    Looks like a good method for exiting following a detected license violation...
    I'd much prefer an HCF then an HLT for those people

    Leave a comment:


  • Stanley Durham
    replied
    works as advertised on Vista and 7, notebook

    Code:
    A Real Programmer would always exit his program under control, and do it the right way, reaching the logical end of the WinMain() function.
    Real programmers have test code and production code.
    Real programmers use shortcuts to get test code up to production standard.

    Leave a comment:


  • Chris Holbrook
    replied
    Looks like a good method for exiting following a detected license violation...

    Leave a comment:


  • Michael Mattias
    replied
    Shame on you for even suggesting this!

    A Real Programmer would always exit his program under control, and do it the right way, reaching the logical end of the WinMain() function.

    Leave a comment:


  • Paul Dixon
    replied
    Stan,
    HLT is a privileged instruction and can't be executed in user mode.
    How your system responds to it depends on how it is set up to handle errors. It's likely to call the debugger, Dr.Watson or try to contact Microsoft to see if it is a known error.
    On my PC I get OllyDebug popping up.

    Paul.

    Leave a comment:


  • Stanley Durham
    started a topic Halt Macro

    Halt Macro

    outdated


    xxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxx

    kill program with error message

    may be used like Assert in some languages.
    - define %HaltActive for test code
    - un-define for production code

    changed: 10/31/2009

    Code:
    '
    '   won't execute unless %HaltActive is defined
    '
    Sub Halt(ByVal message As String)
        #If %Def(%HaltActive)
            ? message
            !HLT
        #EndIf
    End Sub
    '
    Last edited by Stanley Durham; 1 Nov 2009, 10:55 AM.
Working...
X