Menu

There is an unknown macro here somewhere message in versions after 1.89

2020-09-27
2020-09-29
  • Robert Watson

    Robert Watson - 2020-09-27

    Hi,
    We use xll+ from https://www.planatechsolutions.com/xllplus/ to produce an Excel addin providing new Excel functions.
    We have been able to use CppCheck up to version 1.89.
    With versions after 1.89 we get the msg

    " There is an unknown macro here somewhere. Configuration is required. If IMPLEMENT_XLLFN4 is a macro then please configure it. "

    for each code module and then no checks are performed for that code module.

    The function code below includes header file #include "showerror.h", which includes header file #include <xllplus.h> ,
    which includes header file #include <xlpfuncinit.h> which contains the following definition.</xlpfuncinit.h></xllplus.h>

    #define IMPLEMENT_XLLFN4(nmEntryPoint, nmEntryPoint4, nmEntryPoint12, \
                                                                                                    pszArgTemplate4, pszArgTemplate12, \
                                                                                                    pszName, pszArgNames4, pszArgNames12, \
                                                                                                    pszCategory4, pszCategory12, \
                                                                                                    pszHelpText4, pszHelpText12, \
                             pszArgHelpText4, pszArgHelpText12, \
                                                                                                    usHelpTopic, pszHelpTopic, \
                                                                                                    pszExt12, usType, usMinVersion, usMaxVersion) \
    static XLLFN _xfn_##nmEntryPoint = { \
        0, #nmEntryPoint4, #nmEntryPoint12, pszArgTemplate4, pszArgTemplate12, \
                    pszName, pszArgNames4, pszArgNames12, usType, pszCategory4, pszCategory12, \
                    "", usHelpTopic, pszHelpTopic, pszHelpText4, pszHelpText12, \
        pszArgHelpText4, pszArgHelpText12, 0, pszExt12, usMinVersion, usMaxVersion }; \
    static const XLLFN_INIT _init_xfn_##nmEntryPoint(&_xfn_##nmEntryPoint);
    

    The module containg function code which produces error

    // showerror.cpp : Defines the initialization routines for the DLL.
    //
    
    #ifdef XLL_LIB_MFC
    #include "stdafx.h"
    #endif
    #include "showerror.h"
    
    #ifdef _DEBUG
    #ifdef XLL_LIB_MFC
    #define new DEBUG_NEW
    #endif
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    
    /////////////////////////////////////////////////////////////////////////////
    // CshowerrorApp
    
    #ifdef XLL_LIB_MFC
    BEGIN_MESSAGE_MAP(CshowerrorApp, CXllApp)
        //{{AFX_MSG_MAP(CshowerrorApp)
            // NOTE - the ClassWizard will add and remove mapping macros here.
            //    DO NOT EDIT what you see in these blocks of generated code!
        //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    #endif
    
    /////////////////////////////////////////////////////////////////////////////
    // CshowerrorApp construction
    
    CshowerrorApp::CshowerrorApp()
    {
        // TODO: add construction code here,
        // Place all significant initialization in InitInstance
    }
    
    /////////////////////////////////////////////////////////////////////////////
    // The one and only CshowerrorApp object
    
    CshowerrorApp theApp;
    
    /* static */ LPCTSTR CshowerrorApp::m_pszDefName = _T("showerror");
    
    BOOL CshowerrorApp::InitInstance()
    {
        // Call the base class
        if ( !CXllApp::InitInstance() )
            return FALSE;
    
        // Set the name of the library to the default value
        m_stName = m_pszDefName;
    
        // Add the statically defined function specifications
        AddStaticFns();
    
        // TODO: Add your specialized code here
    
        return TRUE;
    }
    
    int CshowerrorApp::ExitInstance()
    {
        // TODO: Add your specialized code here (then call the base class)
    
        return CXllApp::ExitInstance();
    }
    
    BOOL CshowerrorApp::OnXllOpenEx()
    {
        // TODO: Allocate any application-level resources
        return TRUE;
    }
    
    void CshowerrorApp::OnXllClose()
    {
        // TODO: Clean up any application-level resources
    }
    
    /////////////////////////////////////////////////////////////////////////////
    // Exported functions
    
    // TODO: Add your own add-in functions and their associated
    //       macros here
    
    
    // Function:    NewFn1
    // Purpose:
    
    //{{XLP_SRC(NewFn1)
                    // NOTE - the FunctionWizard will add and remove mapping code here.
                    //    DO NOT EDIT what you see in these blocks of generated code!
    
    #pragma region NewFn1 support code
    IMPLEMENT_XLLFN4(NewFn1, NewFn1_4, NewFn1_12, "RJ", "UJ$", L"NewFn1", 0, L"Arg"
                    L"1", 0, L"14", 0, L"", 0, L"\0", 0, 0, L"{NewFn1,,,{},14,1,1,U,{{0,{Arg1,"
                    L"Int,0,,,,,,}}},{},3,,0,0,,,,0,0}", 1, 0, 0)
    CXlOper* NewFn1_Impl(CXlOper&, long);
    extern "C" __declspec(dllexport)
    LPXLOPER12 NewFn1_12(long Arg1)
    {
                    XLL_FIX_STATE;
                    CXlOper xloResult;
                    try {
                                    CXlStructuredExceptionHandler _seh_;
                                    xloResult.HandleResult(NewFn1_Impl(xloResult, Arg1));
                    }
                    catch(const CXlRuntimeException& ex) {
                                    CXllApp::Instance()->DisplayException(xloResult, ex);
                    }
                    XLP_CATCH_CLR_EXCEPTIONS_TO(xloResult)
                    return xloResult.Ret12();
    }
    extern "C" __declspec(dllexport)
    LPXLOPER4 NewFn1_4(long Arg1)
    {
                    XLL_FIX_STATE;
                    CXlOper xloResult;
                    try {
                                    CXlStructuredExceptionHandler _seh_;
                                    xloResult.HandleResult(NewFn1_Impl(xloResult, Arg1));
                    }
                    catch(const CXlRuntimeException& ex) {
                                    CXllApp::Instance()->DisplayException(xloResult, ex);
                    }
                    XLP_CATCH_CLR_EXCEPTIONS_TO(xloResult)
                    return xloResult.Ret4();
    }
    
    #pragma endregion
    
    CXlOper* NewFn1_Impl(CXlOper& xloResult, long Arg1)
    {
                    // End of generated code
    //}}XLP_SRC
                    // TODO - set the value of xloResult, or return another value
                    //                  using CXlOper::RetXXX() or throw a CXlRuntimeException.
                    return xloResult.Ret();
    }
    
     

    Last edit: Daniel Marjamäki 2020-09-27
  • Daniel Marjamäki

    I recommend that you create a "xllplus.cfg" file. Here is a start:

    <?xml version="1.0"?>
    <def format="2">
      <define name="IMPLEMENT_XLLFN4(nmEntryPoint, nmEntryPoint4, nmEntryPoint12, pszArgTemplate4, pszArgTemplate12, pszName, pszArgNames4, pszArgNames12, pszCategory4, pszCategory12, pszHelpText4, pszHelpText12, pszArgHelpText4, pszArgHelpText12, usHelpTopic, pszHelpTopic, pszExt12, usType, usMinVersion, usMaxVersion)" value=""/>
    </def>
    

    That solves your problem:

    danielm@edge:~/cppcheck$ ./cppcheck --library=mfc fp1.cpp
    Checking fp1.cpp ...
    fp1.cpp:93:1: error: There is an unknown macro here somewhere. Configuration is required. If IMPLEMENT_XLLFN4 is a macro then please configure it. [unknownMacro]
    IMPLEMENT_XLLFN4(NewFn1, NewFn1_4, NewFn1_12, "RJ", "UJ$", L"NewFn1", 0, L"Arg"
    ^
    Checking fp1.cpp: XLL_LIB_MFC...
    Checking fp1.cpp: XLL_LIB_MFC;_DEBUG...
    Checking fp1.cpp: _DEBUG...
    

    Using the file:

    danielm@edge:~/cppcheck$ ./cppcheck --library=mfc --library=xllplus fp1.cpp
    Checking fp1.cpp ...
    Checking fp1.cpp: XLL_LIB_MFC...
    Checking fp1.cpp: XLL_LIB_MFC;_DEBUG...
    Checking fp1.cpp: _DEBUG...
    

    If you configure some xllplus macros and functions then feel free to share your xllplus.cfg with us. I would be happy to distribute it in Cppcheck.

     
  • Robert Watson

    Robert Watson - 2020-09-29

    Hi Daniel,
    Thanks for your response .
    I've created a cfg file with your statements and placed it in the cfg folder.
    How do I use it with the gui cppcheck?
    Rob

     
  • Daniel Marjamäki

    in the gui, create a project file.

    in the "Types and Functions" tab, select all configurations that you use.

    if you have a custom cfg file, you can put it in the same folder as the project file is in.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.