User forums > General (but related to Code::Blocks)

using macros wxCHECK_MSG(..,..,..)

(1/3) > >>

omlk:
I was looking through the code and came across these edits, and I want to know if everything was done correctly with regards to the macro?modified: 2022-05-21    ollydbg
--- Code: ---   
m_RE_Unix.Compile(_T("([^$]|^)(\\$[({]?(#?[A-Za-z_0-9.]+)[\\)} /\\\\]?)"), wxRE_EXTENDED | wxRE_NEWLINE);     wxCHECK_MSG(m_RE_Unix.IsValid(), false, "Invalid regex (m_RE_Unix) in macros manager");

--- End code ---
https://sourceforge.net/p/codeblocks/code/12880/tree/trunk/src/sdk/macrosmanager.cpp
macrosmanager.cpp: row 93

My test example:

--- Code: ---#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define wxCHECK2_MSG(cond, op, msg)                                       \
    if ( cond )                                                           \
    {                                                                     \
        printf("cond:%d",(int)cond);                                      \
    }                                                                     \
    else                                                                  \
    {                                                                     \
        printf("op:%s \"%s\" %s:%d",#op,msg,__FILE__,__LINE__);           \
        op;                                                               \
    }
    //struct wxMAKE_UNIQUE_NAME(wxDummyCheckStruct) /* to force a semicolon */

// check which returns with the specified return code if the condition fails
#define wxCHECK_MSG(cond, rc, msg)   wxCHECK2_MSG(cond, return rc, msg)

int test() {
    return -55550; // test 1
//    return 0; // test 2
}

int main(int argc, char** argv) {

    // MACROS, not need ";" in end line
    wxCHECK_MSG(test(), 1212121, "Error msg string.")

    printf("\n%s:%d",__FILE__,__LINE__);
    return 0;

}

--- End code ---

ollydbg:

--- Quote from: omlk on November 12, 2023, 10:17:45 pm ---modified: 2022-05-21 ollydbg

--- End quote ---

Is that code changed by me?

Code::Blocks / SVN Repo / Commit [r12880]

r12880 does not contains your mentioned changes.

Any way, I don't know what's issue you see.

omlk:

--- Quote from: ollydbg on November 13, 2023, 02:55:11 am ---
--- Quote from: omlk on November 12, 2023, 10:17:45 pm ---modified: 2022-05-21 ollydbg

--- End quote ---

--- End quote ---
I saw this information here
https://sourceforge.net/p/codeblocks/code/12880/tree/trunk/src/sdk/
 and did not mean that you added the use of a macro. I wanted to show that in this revision [r12880] there is a use of maros.
If specifically, then it seems here [r12513] (31.9 kB) by  fuscated 2021-08-15 11:51:16

The point is, does the author of the changes really know how this macro works and the behavior will be correct in the event of a compilation error of the expression?

Miguel Gimenez:

--- Quote ---Does the author of the changes really know how this macro works and the behavior will be correct in the event of a compilation error of the expression
--- End quote ---

You can bet he knows. MacrosManager::CompileRegexes() will return false if any of the IsValid() calls return false.

omlk:

--- Quote from: Miguel Gimenez on November 13, 2023, 09:06:22 am ---You can bet he knows. MacrosManager::CompileRegexes() will return false if any of the IsValid() calls return false.

--- End quote ---
I'm not talking about the  MacrosManager::CompileRegexes(), but about the
--- Code: ---wxCHECK_MSG(m_RE_Unix.IsValid(), false, "Invalid regex (m_RE_Unix) in macros manager");
wxCHECK_MSG(m_RE_DOS.IsValid(), false, "Invalid regex (m_RE_DOS) in macros manager");
wxCHECK_MSG(m_RE_IfSp.IsValid(), false, "Invalid regex (m_RE_IfSp) in macros manager");
--- End code ---
processing and output of information where there is an incorrect regular expression. If there is an error in the 1st reg.expression, will the following reg.expressions, which are in the code below, be checked?
What does the second argument as "FALSE" mean?

--- Code: ---wxCHECK_MSG(.., false,..);
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version