Menu

error(Declaration terminated incorrectly) occurs in memory.h

y o
2018-09-12
2018-10-19
  • y o

    y o - 2018-09-12

    Thank you for building OWLNext project.
    I post here for the first time.

    I have imported newest OWLNext into C++ Builder 10.2.
    When I build my project, errors occur in memory.h like below:

    This memory.h is included originally in OWLNext (as seen below URL).
    http://owlnext.sourceforge.net/help/html/dc/d18/memory_8h_source.html

    I have no idea why this error occurs in memory.h which is originally included.
    If you have any information, please let me know...

    -----memory.h
    template<class T> class TCharIterator {
      public:
        TCharIterator(T* p);
        T* Next() const;
        T* Current() const;
        T* operator ++();    // prefix
        T* operator ++(int); // postfix
        operator T*() const;
      protected:
        T* P;                         <<<<<< Error occurs  E2040 Declaration terminated incorrectly
    };
    

    E2040

     

    Last edit: Ognyan Chernokozhev 2018-09-23
  • Ognyan Chernokozhev

    Hi,

    Can you please provide more details:
    Which version of OWLNext are you trying to use? 6.44?
    Is the error happening when you are building OWLNext libraries, or your project?
    Are you using the classig Bcc compiler, or the new CLang one?

    Jogy

     
  • y o

    y o - 2018-09-29

    Hi, Jogy. Thank you for replying.
    Version is 6.44 and compiler is the one for 10.2 ( not classic one.)
    Error is happening when I build my project.

    My original project is made with Borland C++ 5.
    When I tried to build on 10.2 once, E2303 is happening because of TWindow.
    I added '#include "mdi.h"', so E2303 was disappeared.
    But E2040 appeared in memory.h.
    Memory.h is included by mdi.h like below.
    (owl/mdi.h -> owl/private/defs.h -> owl/private/memory.h)

    E2303
    http://docwiki.embarcadero.com/RADStudio/Tokyo/en/E2303_Type_name_expected_(C%2B%2B)

    mdi.h
    http://owlnext.sourceforge.net/help/html/dd/dd2/mdi_8h.html

    defs.h
    http://owlnext.sourceforge.net/help/html/dd/d72/owl_2defs_8h_source.html

    I have no idea why the original source can work without mdi.h..

     

    Last edit: y o 2018-09-29
  • Vidar Hasfjord

    Vidar Hasfjord - 2018-09-30

    Looking at the odd error message at T* P. Is "P" declared as a macro in your project, by any chance?

     
  • y o

    y o - 2018-10-08

    Hi Vidar, thank you for giving a good idea.
    In my project, what I have found is only below.
    Is this "P" to convert to traditional C to ANSI C?

    #if defined(xxx)
    P      About_window *About;
    #endif
    
     
  • Vidar Hasfjord

    Vidar Hasfjord - 2018-10-08

    OWLNext does not define "P". Seeing the way "P" is used in your code snippet, it indeed looks like "P" is a macro (perhaps defined as type qualifier). If so, you will have to rename it to something else and unique, and replace all uses of it in your program, so that it does not conflict with OWLNext.

    PS. If you cannot find the definition, note that macros may be defined in the project settings (or in the command line options invoking the compiler).

     

    Last edit: Vidar Hasfjord 2018-10-08
  • y o

    y o - 2018-10-19

    Thank you for giving a very good idea for me..
    Your point is correct.
    I've finally found the definition of "P" in ".rh" file.
    (Sorry for late reply, because I studied for my project setting...)

    #if defined(xxx)
    #define P
    #endif
    

    I haven't renamed this "P" yet because source codes have many "P" (so I lost heart today...)
    But I will DO that absolutely and I really appreciate your help.
    May happiness be with you...

     

    Last edit: y o 2018-10-19
  • Vidar Hasfjord

    Vidar Hasfjord - 2018-10-19

    Hi yo, good to hear that you found the source of the problem and that my hint was of help.

    Sometimes another set of eyes spots what the first didn't see. :-)

    TIP: Always include ".rh" files last in source files, and avoid including ".rh" files in headers if you can. This way, any macro definitions they include cause minimal trouble.

     

    Last edit: Vidar Hasfjord 2019-01-08

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB